-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
bpo-34831: Asyncio tutorial #9748
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
16d3b94
Create basic structure of the asyncio tutorial
cjrh 50a901e
Begun work on the case study for the server
cjrh dfede40
Incorporate review comments from @willingc
cjrh a11e659
Refine language around threads and processes
cjrh 7e205d2
Incorporate message handling into server code
cjrh 7f2f149
Add message receiving to server code.
cjrh 61402e1
Added skeleton suggestions for the cookbook section
cjrh 550bdbf
Further notes in the cookbook
cjrh e7bc56d
Further work on describing how async def functions work
cjrh 3d4cdae
Fix review comment from @tirkarthi
cjrh e0bb48b
Fix typo
cjrh 5e4550a
Clarify the "What is async" section
cjrh 0de2748
Flesh out the sync-versus-async functions section
cjrh 89364f8
Add the blurb entry
cjrh be474f4
Remove TODOs
cjrh c403101
Write "Executing Async Functions"
cjrh 69190b8
Fix spurious backtick
cjrh 89f7ca2
Make the case study (server) a little neater.
cjrh 36fc743
Some refactoring and finishing off the server.
cjrh d55d8fb
Cleaned up the last bit of the chat server code sample.
cjrh 34306f0
Further progress - got a CLI chat client working using prompt-toolkit.
cjrh 0c82755
Include chat client code in the text.
cjrh a774a98
Fix typo
cjrh eedbc97
Clarify switching behaviour
cjrh a8a801d
Add async generators and async context managers discussion.
cjrh 8e6dcfd
Add some comparison with JavaScript async/await and asyncio.create_task
cjrh 0e5ed3f
Fix "no good read" typo
cjrh 4714ed2
Fix "do not required" typo
cjrh d71da67
Modern -> modern
cjrh 26cc634
Removing the GUI case study section
cjrh 9530021
Remove problematic backticks inside a code-block
cjrh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Further notes in the cookbook
- Loading branch information
commit 550bdbf43ae9cc41eecaa631822a2c9ec572caa9
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -19,6 +19,26 @@ Using A Queue To Control A Pool of Resources | |||||
| - show example with a pool of workers | ||||||
| - show example with a connection pool | ||||||
|
|
||||||
| Best Practices For Timeouts | ||||||
| --------------------------- | ||||||
|
|
||||||
| - start with ``asyncio.wait_for()`` | ||||||
| - also look at ``asyncio.wait()``, and what to do if not all tasks | ||||||
|
Contributor
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.
Suggested change
|
||||||
| are finished when the timeout happens. Also look at the different | ||||||
| termination conditions of ``asyncio.wait()`` | ||||||
|
|
||||||
| How To Handle Cancellation | ||||||
| -------------------------- | ||||||
|
|
||||||
| - app shutdown | ||||||
| - how to handle CancelledError and then close sockets | ||||||
|
Contributor
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.
Suggested change
|
||||||
| - also, when waiting in a loop on ``await queue.get()`` is it better to | ||||||
| handle CancelledError, or use the idiom of putting ``None`` on the | ||||||
| queue? (``None`` would be better because it ensures the contents of the | ||||||
| queue get processed first, but I don't think we can prevent | ||||||
| CancelledError from getting raised so it must be handled anyway. I | ||||||
| can make an example to explain better.) | ||||||
|
|
||||||
| Keeping Track Of Many Connections | ||||||
| --------------------------------- | ||||||
|
|
||||||
|
|
@@ -105,6 +125,9 @@ TODO | |||||
| if __name__ == '__main__': | ||||||
| asyncio.run(main()) | ||||||
|
|
||||||
| - we should also include a brief discussion of "when to use asyncio.gather and | ||||||
| when to use asyncio.wait" | ||||||
|
|
||||||
| Secure Client-Server Networking | ||||||
| ------------------------------- | ||||||
|
|
||||||
|
|
@@ -197,6 +220,8 @@ Handling Typical Socket Errors | |||||
|
|
||||||
| Might also want to show some examples of ``asyncio.IncompleteReadError``. | ||||||
|
|
||||||
| Also link/refer to the socket programming HOWTO in the docs. | ||||||
|
|
||||||
| Graceful Shutdown on Windows | ||||||
| ---------------------------- | ||||||
|
|
||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.