On Sep 26, 2013, at 6:51 PM, Jonathan Vanasco email@example.com wrote:
Quick question about (sub)processes in twisted :
how bad is it to use the subprocess module ? ( in general / in this application )
It's pretty bad ;-).
I have the following setup :
- Twisted Daemon that does 5 things (very well!)
- A new requirement -- to execute 2 scripts on the commandline , one after the other ( ie, blocking )
the 2 commandline scripts are just tossing some PostgreSQL commands via `postgresql db < file.txt`
i was looking at reactor.SpawnProcess -- which I know is more correct. it just seems to be a bit annoying to use , and I know the subprocess module already.
The subprocess module does not have any way to spawn a subprocess and get its output and exit status as events in the reactor; its methods all block. You can sort of re-build spawnProcess yourself from scratch, but ... then you'd just have spawnProcess with a slightly more subprocess-y API, and you'd be better off writing a utility function that wraps spawnProcess for yourself.
Could you write up why you feel it's "annoying"? Maybe we can improve spawnProcess so it works better for you in the future.