Prepare the run loop to process events. This method exists so that custom event loop subclasses (e.g., event loops that integrate a GUI event loop with Python's event loop) have access to all the loop setup logic.
(self)
| 634 | 'Cannot run the event loop while another loop is running') |
| 635 | |
| 636 | def _run_forever_setup(self): |
| 637 | """Prepare the run loop to process events. |
| 638 | |
| 639 | This method exists so that custom event loop subclasses (e.g., event loops |
| 640 | that integrate a GUI event loop with Python's event loop) have access to all the |
| 641 | loop setup logic. |
| 642 | """ |
| 643 | self._check_closed() |
| 644 | self._check_running() |
| 645 | self._set_coroutine_origin_tracking(self._debug) |
| 646 | |
| 647 | self._old_agen_hooks = sys.get_asyncgen_hooks() |
| 648 | self._thread_id = threading.get_ident() |
| 649 | sys.set_asyncgen_hooks( |
| 650 | firstiter=self._asyncgen_firstiter_hook, |
| 651 | finalizer=self._asyncgen_finalizer_hook |
| 652 | ) |
| 653 | |
| 654 | events._set_running_loop(self) |
| 655 | |
| 656 | def _run_forever_cleanup(self): |
| 657 | """Clean up after an event loop finishes the looping over events. |