Bug in os.spawnv with P_NOWAIT
nushin
nushin2 at yahoo.com
Wed Aug 6 21:38:11 EDT 2003
If you do not null out the output of your parent process that launches
a child process by os.spawnv( ) in P_NOWAIT mode, you will see that
your child process is launched *synchronously* instead of
asynchronously. This is a bug!
Here's a code sample:
In your parent.py file, call child.py as
os.spawnv(os.P_NOWAIT,'/usr/bin/python',('python', 'child.py'))
then, make sure your child.py prints a *hello child* to screen about
2000000 times, and your parent.py prints a *hello parent* message,
then execute your file in a shell as:
python parent.py
then, you would see that whenever your child.py is finished, then
parent.py finishes, i.e., a synchronous call.
Now, null out the output of your parent process as:
python parent.py > /dev/null
then, your parent.py finishes first while child.py is still running,
i.e., an asynchronous call. Please correct me if i am wrong.
Regards,
Nushin
More information about the Python-list
mailing list