Message193646
Popen() ought to support redirection to/from more file descriptors than 0, 1, and 2 when spawning processes. A clear use case is here: http://stackoverflow.com/questions/6050187/write-to-file-descriptor-3-of-a-python-subprocess-popen-object
Instead of messing around with os.open() and os.close() calls, my proposed API for Popen would be to accept keyword arguments fdN that would take the same type of values as the stdin, stdout, stderr arguments. Conflicting fd0 and stdin arguments would throw an exception.
So the smelly code in the above SO question would be changed to:
cmd='gpg --passphrase-fd {fd} -c'.format(fd=fd)
with open('passphrase.txt','r') as fd3_fh:
with open('filename.txt','r') as stdin_fh:
with open('filename.gpg','w') as stdout_fh:
proc=subprocess.Popen(shlex.split(cmd),
stdin=stdin_fh,
stdout=stdout_fh,
fd3=fd3_fh)
proc.communicate() |
|
Date |
User |
Action |
Args |
2013-07-24 14:00:00 | ropoctorix | set | recipients:
+ ropoctorix |
2013-07-24 14:00:00 | ropoctorix | set | messageid: <1374674400.76.0.00470955001934.issue18544@psf.upfronthosting.co.za> |
2013-07-24 14:00:00 | ropoctorix | link | issue18544 messages |
2013-07-24 14:00:00 | ropoctorix | create | |
|