Stops running threads and wait for them to exit, if necessary. Should be called by the same thread which called `start()`. Arguments: timeout: maximum time to wait on `thread.join()`
(self, timeout=None)
| 652 | _SHARED_SEQUENCES[self.uid] = self.sequence |
| 653 | |
| 654 | def stop(self, timeout=None): |
| 655 | """Stops running threads and wait for them to exit, if necessary. |
| 656 | |
| 657 | Should be called by the same thread which called `start()`. |
| 658 | |
| 659 | Arguments: |
| 660 | timeout: maximum time to wait on `thread.join()` |
| 661 | """ |
| 662 | self.stop_signal.set() |
| 663 | with self.queue.mutex: |
| 664 | self.queue.queue.clear() |
| 665 | self.queue.unfinished_tasks = 0 |
| 666 | self.queue.not_full.notify() |
| 667 | self.run_thread.join(timeout) |
| 668 | _SHARED_SEQUENCES[self.uid] = None |
| 669 | |
| 670 | def __del__(self): |
| 671 | if self.is_running(): |