Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- from multiprocessing import Pool, Lock
- class ParentApp():
- mutex=Lock()
- def report(self,msg):
- with ParentApp.mutex:
- sys.stdout.write(msg)
- class ChildApp1(ParentApp):
- def print_report(self):
- for i in xrange(100):
- ParentApp.report(self, 'BLABLA')
- class ChildApp2(ParentApp):
- def print_report(self):
- for i in xrange(100):
- ParentApp.report(self, 'TESTTEST')
- def runnable(app):
- app.print_report()
- def main():
- app=[]
- app.append(ChildApp1())
- app.append(ChildApp2())
- pool = Pool(len(apps))
- pool.map(runnable, apps)
- exit(0)
- if __name__ == '__main__':
- sys.exit(main())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement