From 21b7202f1fc525ac001eee5667dfe6c4794b34bc Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 17 Jul 2019 15:20:15 +0200 Subject: [PATCH] Clarify declaring function async (#293) The import and decorator syntax was Python 3.4, with Python 3.5 this became much nicer and the async keyword is now used. Use awaited instead of yielded, which makes it easier to read. --- docs/asyncio_categorizing_functions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/asyncio_categorizing_functions.md b/docs/asyncio_categorizing_functions.md index ff14c90b..b03650a6 100644 --- a/docs/asyncio_categorizing_functions.md +++ b/docs/asyncio_categorizing_functions.md @@ -10,9 +10,9 @@ Home Assistant uses the convention that all functions that must be run from with Coroutines are special functions based on Python’s generators syntax which allows them to suspend execution while waiting on a result. -Invoking a coroutine function will return a Generator object back, but will not actually begin execution. This object will execute the task when it is either yielded from (from within another coroutine) or it is scheduled on the event loop. +Invoking a coroutine function will return a Generator object back, but will not actually begin execution. This object will execute the task when it is either awaited (from within another coroutine) or it is scheduled on the event loop. -To declare a function a coroutine, import the coroutine annotation from the asyncio package and annotate your function. +To declare a function a coroutine, add `async` before the `def` of the function definition. ```python async def async_look_my_coroutine(target):