File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
Doc/library/asyncio-tutorial Expand file tree Collapse file tree 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:
99 def f (x , y ):
1010 print (x + y)
1111
12+ # Evaluate the function
1213 f(1 , 2 )
1314
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:
1616
1717.. code-block :: python
1818
@@ -21,13 +21,17 @@ different in two respects:
2121 async def f (x , y ):
2222 print (x + y)
2323
24+ # Execute the *async* function above
2425 asyncio.run(f(1 , 2 ))
2526
2627 The first difference is that the function declaration is spelled
2728``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
2930from the ``asyncio `` module.
3031
32+ Executing Async Functions
33+ -------------------------
34+
3135The ``run `` function is only good for executing an async function
3236from "synchronous" code; and this is usually only used to execute
3337a "main" async function, from which others can be called in a simpler
Original file line number Diff line number Diff line change 11Asyncio Tutorial
22================
33
4- Programming with ``async def `` functions is different to normal Python
4+ Programming with ``async def `` functions is differs from normal Python
55functions; enough so that it is useful to explain a bit more
66about what ``asyncio `` is for, and how to use it in typical
77programs.
You can’t perform that action at this time.
0 commit comments