In Python under Windows: I want to run some code in a separate process. And I don\'t want the parent waiting for it to end. Tried this:
from multiprocessing impo
Use the subprocess
module as other subprocess control methods (os.system, os.spawn*, os.popen*, popen2., commands.) are being deprecated:
from subprocess import Popen
Popen( [ "foo.exe", "arg1", "arg2", "arg3" )
See the Python doco, especially P_NOWAIT example.
You will have to start a new Python interpreter in the subprocess, so "foo.exe" above will likely be "python.exe".
EDIT:
Having just reviewed the multiprocessing module documentation:
join_thread()
: Join the background thread. This can only be used after close() has been called. It blocks until the background thread exits, ensuring that all data in the buffer has been flushed to the pipe.By default if a process is not the creator of the queue then on exit it will attempt to join the queue’s background thread. The process can call
cancel_join_thread()
to makejoin_thread()
do nothing.
cancel_join_thread()
: Preventjoin_thread()
from blocking. In particular, this prevents the background thread from being joined automatically when the process exits – seejoin_thread()
.
It looks like you should be able to call cancel_join_thread()
to get the behaviour you desire. I've never used this method (and was unaware of it's existence until a minute ago!), so be sure to let us know if it works for you.