Skip to content

Instantly share code, notes, and snippets.

@nikparmar
Created March 29, 2017 18:57
Show Gist options
  • Save nikparmar/278f4ef5bcc2a8fcc4b3b2b01fd84090 to your computer and use it in GitHub Desktop.
Save nikparmar/278f4ef5bcc2a8fcc4b3b2b01fd84090 to your computer and use it in GitHub Desktop.
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