Can somebody help me understand why is my code executed twice?
import multiprocessing
from time import sleep
import os, signal
def neverEnding():
while True:
print ' Looping ... '
sleep(3)
p = multiprocessing.Process(target=neverEnding)
p.start()
sleep(10)
print p.is_alive()
print p.pid
p.terminate()
print p.is_alive()
print 'terminated?'
os.kill(int(p.pid), signal.SIGTERM)
print 'Now?'
sleep(3)
print p.is_alive()
This is the output I'm getting.
Looping ...
Looping ...
Looping ...
Looping ...
True
8999
True
terminated?
Now?
False
Looping ...
Looping ...
Looping ...
Looping ...
True
9000
True
terminated?
Now?
False
I'm getting 'terminated?', 'Now?' etc... printed twice.
Can somebody explain why does this happen?
Will the other processes running in the background cause this? (I had run the same script using subprocess before)
I'm using Ubuntu.