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