Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from concurrent.futures import ProcessPoolExecutor, as_completed
- class Foo:
- def __init__(self):
- self.spam = 'eggs'
- def bar(self):
- self.spam = 42
- print('4242')
- def doge(self):
- print(self.spam)
- with ProcessPoolExecutor(2) as pool:
- futures = [pool.submit(self.bar) for i in range(3)]
- for future in as_completed(futures):
- pass
- print(self.spam)
- if __name__ == '__main__':
- wow = Foo()
- wow.doge()
Add Comment
Please, Sign In to add comment