Created
March 29, 2017 18:57
-
-
Save nikparmar/278f4ef5bcc2a8fcc4b3b2b01fd84090 to your computer and use it in GitHub Desktop.
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 | |
class runner(object): | |
jobs =[] | |
def worker(self, x): | |
return x*x | |
def starter(self): | |
p = multiprocessing.Process(target=self.worker, args=(2,)) | |
self.jobs.append(p) | |
p.start() | |
print "start" | |
return p | |
def run(self): | |
if __name__ == '__main__': | |
for i in range(10): | |
a = self.starter() | |
print "now here" | |
for i in self.jobs: | |
i.join() | |
print "here" | |
if i.is_alive() is False: | |
return self.run() | |
print "restarting------" | |
# time.sleep(10) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment