-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
Changes from 1 commit
16d3b94
50a901e
dfede40
a11e659
7e205d2
7f2f149
61402e1
550bdbf
e7bc56d
3d4cdae
e0bb48b
5e4550a
0de2748
89364f8
be474f4
c403101
69190b8
89f7ca2
36fc743
d55d8fb
34306f0
0c82755
a774a98
eedbc97
a8a801d
8e6dcfd
0e5ed3f
4714ed2
d71da67
26cc634
9530021
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -9,10 +9,10 @@ and look like this: | |||||
def f(x, y): | ||||||
print(x + y) | ||||||
|
||||||
# Evaluate the function | ||||||
f(1, 2) | ||||||
|
||||||
The snippet also shows how the function is evaluated. Async functions are | ||||||
different in two respects: | ||||||
Async functions are different in two respects: | ||||||
|
||||||
.. code-block:: python | ||||||
|
||||||
|
@@ -21,13 +21,17 @@ different in two respects: | |||||
async def f(x, y): | ||||||
print(x + y) | ||||||
|
||||||
# Execute the *async* function above | ||||||
asyncio.run(f(1, 2)) | ||||||
cjrh marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
10000 |
|
|||||
The first difference is that the function declaration is spelled | ||||||
``async def``. The second difference is that async functions cannot be | ||||||
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
|
||||||
executed by simply evaluating them. Here, we use the ``run()`` function | ||||||
executed by simply evaluating them. Instead, we use the ``run()`` function | ||||||
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
|
||||||
from the ``asyncio`` module. | ||||||
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
|
||||||
|
||||||
Executing Async Functions | ||||||
------------------------- | ||||||
|
||||||
The ``run`` function is only good for executing an async function | ||||||
cjrh marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
from "synchronous" code; and this is usually only used to execute | ||||||
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
|
||||||
a "main" async function, from which others can be called in a simpler | ||||||
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
|
||||||
|
Uh oh!
There was an error while loading. Please reload this page.