Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-110771: Decompose run_forever() into parts#110773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
a0c1fde67bfc8f3dcf97b35271dc6672f6854349c3e6226a523852d0e7f892ef94494431431261b3e3d8File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -215,36 +215,48 @@ Running and stopping the loop | ||
| Set up an event loop so that it is ready to start actively looping and | ||
| processing events. | ||
| .. note:: | ||
| End users should not use this method directly. This method is only needed | ||
| if you are writing your own ``EventLoop`` subclass, with a customized | ||
| event processing loop. For example, if you are integrating Python's | ||
| asyncio event loop with a GUI library's event loop, you may need to write | ||
| a customized :meth:`loop.run_forever` implementation that accommodates | ||
| both CPython's event loop and the GUI library's event loop. You can use | ||
| this method to ensure that Python's event loop is correctly configured and | ||
| ready to start processing events. | ||
| The specific details of a customized ``EventLoop`` subclass will depend | ||
| on the GUI library you are integrating with. However, the broad structure | ||
| of a custom ``EventLoop`` would look something like:: | ||
| class CustomGUIEventLoop(EventLoop): | ||
| def run_forever(self): | ||
| try: | ||
| self.run_forever_setup() | ||
| gui_library.setup() | ||
| while True: | ||
| self._run_once() | ||
| gui_library.process_events() | ||
| if self._stopping: | ||
| ||
| break | ||
| finally: | ||
| self.run_forever_cleanup() | ||
| gui_library.cleanup() | ||
| ||
| .. versionadded:: 3.13 | ||
| .. method:: loop.run_forever_cleanup() | ||
| Perform any cleanup necessary at the conclusion of event processing to ensure | ||
| that the event loop has been fully shut down. | ||
| ||
| .. note:: | ||
| End users should not use this method directly. This method is only needed | ||
| if you are writing your own ``EventLoop`` subclass, with a customized | ||
| inner event processing loop. See :meth:`loop.run_forever_setup()` for | ||
| details on why and how to use this method. | ||
| .. versionadded:: 3.13 | ||