popen4 hangs when calling rsync

Brian Nelson bnelson at appservers.us
Thu Apr 10 19:20:41 EDT 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 "
         self._runCmdAndLog(SYNC_CMD)


     def _runCmdAndLogPopen4(self, cmd):
         logger.info("runCmdAndLog")
         re, w = popen2.popen4(cmd)
         while 1:
             logger.info("read next line")
             char = re.readline()
             if not char: break
             logger.info(char)
         logger.info("after command executed")
         re.close()
         w.close()
         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