aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Izan <[email protected]>2021-09-25 23:51:04 +0100
committerGravatar Izan <[email protected]>2021-09-25 23:51:04 +0100
commit7ec98f71b6f650794e26d73a2503bf2e472e1228 (patch)
tree075064b0cc0e75169f9062f02c8f5bbaf3c296c1
parentMerge remote-tracking branch 'origin/tags-revision' into tags-revision (diff)
Bluenix Review #2
This commit should be squashed upon PR merge. - Made some more fixes in `async-await.md`
-rw-r--r--bot/resources/tags/async-await.md4
1 files changed, 2 insertions, 2 deletions
diff --git a/bot/resources/tags/async-await.md b/bot/resources/tags/async-await.md
index a20332df6..e945240ba 100644
--- a/bot/resources/tags/async-await.md
+++ b/bot/resources/tags/async-await.md
@@ -2,7 +2,7 @@
Python provides the ability to run multiple tasks and coroutines simultaneously with the use of the `asyncio` library, which is included in the Python standard library.
-This works by running these coroutines in an event loop, where the context of the running coroutine switches periodically to allow all other coroutines to run, thus giving the appearance of running at the same time. This is different to using threads or processes in that all code runs in the main process and thread, although it is possible to run coroutines in threads.
+This works by running these coroutines in an event loop, where the context of the running coroutine switches periodically to allow all other coroutines to run, thus giving the appearance of running at the same time. This is different to using threads or processes in that all code runs in the main process and thread, although it is possible to run coroutines in other threads.
To call an async function we can either `await` it, or run it in an event loop which we get from `asyncio`.
@@ -11,7 +11,7 @@ To create a coroutine that can be used with asyncio we need to define a function
async def main():
await something_awaitable()
```
-Which means we can call `await something_awaitable()` directly from within the function. If this were a non-async function, this would have raised the exception `SyntaxError: 'await' outside async function`
+Which means we can call `await something_awaitable()` directly from within the function. If this were a non-async function, it would raise the exception `SyntaxError: 'await' outside async function`
To run the top level async function from outside the event loop we need to use `[asyncio.run()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.run), like this:
```py