@@ -1731,19 +1731,18 @@ Asynchronous tasks can create unexpected race conditions in your code.
17311731All trigger decorators call the function as an asynchronous task when the trigger occurs. All tasks
17321732you create explicitly are also asynchronous. This allows each function to run in parallel with
17331733other tasks, and to yield control to other tasks and all other HASS activities potentially anywhere
1734- in the function. However, if two closely-spaced triggers occur (or different functions have the
1734+ in the function. However, if two closely-spaced triggers occur (or multiple functions have the
17351735same trigger), although the second trigger will begin running after the first, there is no guarantee
17361736that the first task will have completed (or even executed any statements) before the second task
17371737start running. Both trigger functions will be running asynchronously, and the order of execution of
1738- code among the tasks is not guaranteed. The same is true if you start two tasks using `` task.create() ``
1739- without any delay: the code in the tasks could run in any order relative to each other.
1738+ your code among the active tasks is not guaranteed. The same is true if you start two tasks using
1739+ `` task.create() `` without any delay: the code in the tasks could run in any order relative to each other.
17401740
17411741If this is a problem for your application logic, various solutions including using ``asyncio.Lock ``
17421742or ``asyncio.Event ``, using ``task.unique() `` to ensure only one task is running at a time, or using
17431743``state_hold `` in the trigger arguments to ensure the trigger condition persists for some time before
17441744triggering the function.
17451745
1746-
17471746Trigger Closures
17481747^^^^^^^^^^^^^^^^
17491748
@@ -2163,7 +2162,7 @@ it doesn't faithfully mimic Python. Here are some areas where pyscript differs
21632162 correct manner. So it's not necessary to use ``async `` and ``await `` in pyscript code - they are optional.
21642163 However, if you declare a function in pyscript as ``async def ``, then it doesn't behave correctly
21652164 like an async function in Python (i.e., calling it actually executes the function, rather than returning
2166- a co-routine. If you truly need an async function in your code, use `@pyscript_compile `.
2165+ a co-routine) . If you truly need an async function in your code, use `@pyscript_compile `.
21672166- All pyscript functions are async. So if you call a Python module that takes a pyscript function as
21682167 a callback argument, that argument is an async function, not a normal function. So a Python module
21692168 won't be able to call that pyscript function unless it uses ``await ``, which requires that function to
0 commit comments