Guest User

Untitled

a guest
Jul 20th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. from concurrent.futures import ProcessPoolExecutor, as_completed
  2.  
  3. class Foo:
  4. def __init__(self):
  5. self.spam = 'eggs'
  6.  
  7. def bar(self):
  8. self.spam = 42
  9. print('4242')
  10.  
  11. def doge(self):
  12. print(self.spam)
  13.  
  14. with ProcessPoolExecutor(2) as pool:
  15. futures = [pool.submit(self.bar) for i in range(3)]
  16. for future in as_completed(futures):
  17. pass
  18.  
  19. print(self.spam)
  20.  
  21.  
  22. if __name__ == '__main__':
  23. wow = Foo()
  24. wow.doge()
Add Comment
Please, Sign In to add comment