File tree 2 files changed +8
-4
lines changed
Doc/library/asyncio-tutorial
2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -9,10 +9,10 @@ and look like this:
9
9
def f (x , y ):
10
10
print (x + y)
11
11
12
+ # Evaluate the function
12
13
f(1 , 2 )
13
14
14
- The snippet also shows how the function is evaluated. Async functions are
15
- different in two respects:
15
+ Async functions are different in two respects:
16
16
17
17
.. code-block :: python
18
18
@@ -21,13 +21,17 @@ different in two respects:
21
21
async def f (x , y ):
22
22
print (x + y)
23
23
24
+ # Execute the *async* function above
24
25
asyncio.run(f(1 , 2 ))
25
26
26
27
The first difference is that the function declaration is spelled
27
28
``async def ``. The second difference is that async functions cannot be
28
- executed by simply evaluating them. Here , we use the ``run() `` function
29
+ executed by simply evaluating them. Instead , we use the ``run() `` function
29
30
from the ``asyncio `` module.
30
31
32
+ Executing Async Functions
33
+ -------------------------
34
+
31
35
The ``run `` function is only good for executing an async function
32
36
from "synchronous" code; and this is usually only used to execute
33
37
a "main" async function, from which others can be called in a simpler
Original file line number Diff line number Diff line change 1
1
Asyncio Tutorial
2
2
================
3
3
4
- Programming with ``async def `` functions is different to normal Python
4
+ Programming with ``async def `` functions is differs from normal Python
5
5
functions; enough so that it is useful to explain a bit more
6
6
about what ``asyncio `` is for, and how to use it in typical
7
7
programs.
You can’t perform that action at this time.
0 commit comments