I'm trying to understand the os.fork function, so I ran a small script I found from this thread,
Regarding The os.fork() Function In Python
#!/usr/bin/env python
import os
def child():
print "We are in the child process with PID= %d"%os.getpid()
def parent():
print "We are in the parent process with PID= %d"%os.getpid()
newRef=os.fork()
if newRef==0:
child()
else:
print "We are in the parent process and our child process has PID= %d"%newRef
parent()
The program runs fine from the command line but not in the repl. I would like to run this script in the repl to explore the behavior interactively. Well after I run os.fork(), the repl becomes very sluggish and unresponsive.
My main question: Is this normal behavior?
If so, why? Running this in the repl isn't too important for me but it would be nice. However, maybe something else combined with calling os.fork() is causing this performance issue...like my OS, or something. Anyways, I'm running Python 3 in Ubuntu 14.04.
Aucun commentaire:
Enregistrer un commentaire