popen4 hangs when calling rsync

Brian Nelson bnelson at appservers.us
Fri Apr 11 01:20:41 CEST 2003

I'm having problems when using popen from within threads. The problem 
only appears when I'm calling rsync. It seems the process never exits. 
It runs fine when run from the main thread of the application.

The code is as follows....

     def syncPortage(self):
         SYNC_CMD = "/usr/bin/rsync -rlptDvz --no-detach --progress 
--stats --delete --delete-after --delete-excluded --timeout=180 
--exclude='distfiles/*' --exclude='packages/*' 
rsync://mirror.appservers.us/appserver /usr/portage "

     def _runCmdAndLogPopen4(self, cmd):
         re, w = popen2.popen4(cmd)
         while 1:
             logger.info("read next line")
             char = re.readline()
             if not char: break
         logger.info("after command executed")
         logger.info("end runCmdAndLog")

Is this a general problem with using popen from within threads? Or is it 
something to do with rsync.

Thanks for your help!

More information about the Python-list mailing list