Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. input_queue = mp.Queue()
  2. output_queue = mp.Queue()
  3. ep = EventProcessor(input_queue, output_queue, name='EventProcessor')
  4.  
  5. ep.start()
  6. ep.request_halt() # sets Event for all threads of the process, such that infinite loop terminates on the next iteration
  7. ep.join()
  8.  
  9. input_queue = mp.Queue()
  10. output_queue = mp.Queue()
  11. new_ep = EventProcessor(input_queue, output_queue, name='EventProcessor')
  12.  
  13. new_ep.start()
  14. new_ep.request_halt()
  15. new_ep.join() # at this point it blocks forever
  16.  
  17. def run(self):
  18. """Launches execution of the process"""
  19. try:
  20. print('before threads start')
  21. for thread in self._threads:
  22. thread.start()
  23. print('threads started')
  24. for thread in self._threads:
  25. thread.join() # when the launched second time it blocks here forever
  26. print('threads joined')
  27. finally:
  28. self._close_closables() # closes associated queues
  29. print('leaving the process')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement