Created
May 22, 2013 11:06
-
-
Save nbari/5626790 to your computer and use it in GitHub Desktop.
restart process
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import multiprocessing | |
import time | |
def worker(num): | |
print 'worker:', num | |
if num == 255: | |
print 'second child' | |
else: | |
exit(255) | |
if __name__ == '__main__': | |
jobs = [] | |
for i in range(5): | |
p = multiprocessing.Process(target=worker, args=(i,)) | |
jobs.append(p) | |
p.start() | |
for j in jobs: | |
j.join() | |
print '%s.exitcode = %s' % (j.name, j.exitcode) | |
if j.exitcode == 255: | |
time.sleep(1) | |
print 'restart proccess' | |
p = multiprocessing.Process(target=worker, args=(255,)) | |
jobs.append(p) | |
p.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment