python - Popen hangs on communicate -


i writing program communicate 2 programs:

output = popen(shlex.split(query_cmd), stdout=pipe,stdin=none) cmd_out = [output.stdout] while cmd_out: readable,writeready,exceptready = select.select(cmd_out,[],[],timeout) f in readable:     line = f.readline()     snap_result=popen(shlex.split("snap %s" % (line) ),stdout=pipe,close_fds=true).communicate()[0]     print snap_result 

supposedly query_cmd continuously generate lines of result. snap should use line argument, return results , terminate. works on python2.4. however, on python2.6.6, seems snap hangs on reading result. if change query_cmd "tail -f file". seems work too.

i running inside csh script both stdout/stderr redirected log file.

edit: actually, weird, in csh, redirected both stdout&stderr log file. if redirect stdout, running fine. if redirect stderr, hangs. think somehow stderr messed between parent process of python , child process.

seems not problem of script because subprocess expecting stdin input. redirect stdin null device solve this.


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -