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 |
|---|---|---|
| @@ -627,7 +627,7 @@ def run_forever_setup(self): | ||
| return (old_agen_hooks,) | ||
| def run_forever_cleanup(self,original_state): | ||
| """Clean up an event loop after the event loop finishes the looping over | ||
| events. | ||
| @@ -637,23 +637,26 @@ def run_forever_cleanup(self, orig_state): | ||
| customized ``run_forever`` semantics (e.g., integrating a GUI event loop | ||
| with Python's event loop). | ||
| """ | ||
| self._stopping = False | ||
| self._thread_id = None | ||
| events._set_running_loop(None) | ||
| self._set_coroutine_origin_tracking(False) | ||
| if original_state is not None: | ||
| old_agen_hooks, = original_state | ||
| sys.set_asyncgen_hooks(*old_agen_hooks) | ||
| def run_forever(self): | ||
| """Run until stop() is called.""" | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Maybe clarify in this docstring that this is what calls setup/cleanup? | ||
| # Ensure original_state has a value in case setup fails. | ||
| original_state = None | ||
| try: | ||
| original_state = self.run_forever_setup() | ||
| while True: | ||
| self._run_once() | ||
| if self._stopping: | ||
| break | ||
| finally: | ||
| self.run_forever_cleanup(original_state) | ||
| def run_until_complete(self, future): | ||
| """Run until the Future is done. | ||