Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
gvanrossum merged 12 commits intopython:mainfromfreakboy3742:decomposed-event-loop
Oct 13, 2023
Merged
Changes from1 commit
Commits
Show all changes
12 commits
Select commitHold shift + click to select a range
a0c1fde
Decompose run_forever() into parts to allow external usage.
freakboy3742Oct 12, 2023
67bfc8f
📜🤖 Added by blurb_it.
blurb-it[bot]Oct 13, 2023
3dcf97b
Add docs for run_forever_setup and run_forever_cleanup.
freakboy3742Oct 13, 2023
35271dc
Ensure failures during setup don't prevent cleanup.
freakboy3742Oct 13, 2023
6672f68
Add tests for custom event loop implementation.
freakboy3742Oct 13, 2023
54349c3
Store pre-event loop state as a protected variable.
freakboy3742Oct 13, 2023
e6226a5
Add a missing super() call.
freakboy3742Oct 13, 2023
23852d0
Improvements to docs, including a prototype custom event loop.
freakboy3742Oct 13, 2023
e7f892e
Correct prototype of run_forever_cleanup on Windows Proactor.
freakboy3742Oct 13, 2023
f944944
Merge branch 'main' into decomposed-event-loop
freakboy3742Oct 13, 2023
3143126
Keep the setup/cleanup methods as protected API.
freakboy3742Oct 13, 2023
1b3e3d8
Merge branch 'main' into decomposed-event-loop
freakboy3742Oct 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Add docs for run_forever_setup and run_forever_cleanup.
  • Loading branch information
@freakboy3742
freakboy3742 committedOct 13, 2023
commit3dcf97b3ee9623c2f716c93dfdcca6c1d16c14ed
38 changes: 38 additions & 0 deletionsDoc/library/asyncio-eventloop.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -210,6 +210,44 @@ Running and stopping the loop
.. versionchanged:: 3.12
Added the *timeout* parameter.

.. method:: loop.run_forever_setup()

Set up an event loop so that it is ready to start actively looping and
processing events.

Returns the state that must be restored when the loop concludes. This state
should be passed in as arguments to :meth:`loop.run_forever_cleanup()`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

"argument" I presume?

Suggested change
should be passed in asarguments to:meth:`loop.run_forever_cleanup()`.
should be passed in asargument to:meth:`loop.run_forever_cleanup()`.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

No longer relevant as I've moved this to be an internal variable.


.. note::

This method is only needed if you are writing your own ``EventLoop``
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Maybe this? Or maybe I misunderstand and the subclass wouldcall this and the cleanup method?

Suggested change
This method is only needed if you are writing your own ``EventLoop``
Overriding this method is only needed if you are writing your own ``EventLoop``

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The usage I'm envisaging (and the usage that would be needed by Toga would be tocall the startup/cleanup methods, but provide a custom "while True: process event" loop that does whatever is needed for integration.

Overriding may also be required - the Windows event loop does this. However, I suspect that's more a case of Python's implementation using subclassing to satisfy the needs of all platforms, rather than something you'll see with GUI integration.

subclass, with a customized inner event processing loop. For example, if
you are integrating Python's asyncio event loop with a 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 individual events. Most
end users will not need to use this method directly.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Maybe stronger?

Suggested change
end userswill notneed to use this method directly.
end usersshould notcall this method directly.

Also below.

Also, I'd like to see a tiny example of how to write such a subclass.

freakboy3742 reacted with thumbs up emoji

.. versionadded:: 3.13

.. method:: loop.run_forever_cleanup(original_state)

Perform any cleanup necessary at the conclusion of event processing to ensure
that the event loop has been fully shut down.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Maybe say something about whether this is re-entrant? Should I worry about not calling it twice?


The *original_state* argument is the return value provided by the call to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
The *original_state* argument is the return valueprovided by the call to
The *original_state* argument is the return valuefrom the call to

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

No longer relevant as I've moved this to be an internal variable.

:meth:`loop.run_forever_setup()` that was used to set up the event loop.

.. note::

This method is only needed if you are writing your own ``EventLoop``
subclass, with a customized inner event processing loop. For example, if
you are integrating Python's asyncio event loop with a GUI library's event
loop, you can use this method to ensure that Python's event loop has been
fully shut down at the conclusion of processing events. Most end users
will not need to use this method directly.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Same as above.

freakboy3742 reacted with thumbs up emoji

.. versionadded:: 3.13

Scheduling callbacks
^^^^^^^^^^^^^^^^^^^^

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp