mirror of
https://github.com/home-assistant/developers.home-assistant.git
synced 2025-07-14 21:06:28 +00:00
Use correct method to run coroutines threadsafe
This commit is contained in:
parent
6041e8382f
commit
b13c07bad4
@ -74,10 +74,10 @@ Sometimes it will happen that you’re in a thread and you want to call a functi
|
|||||||
In the following example, `say_hello` will schedule `async_say_hello` and block till the function has run and get the result back.
|
In the following example, `say_hello` will schedule `async_say_hello` and block till the function has run and get the result back.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from homeassistant.util.async_ import run_callback_threadsafe
|
from homeassistant.util.async_ import run_coroutine_threadsafe
|
||||||
|
|
||||||
def say_hello(hass, target):
|
def say_hello(hass, target):
|
||||||
return run_callback_threadsafe(
|
return run_coroutine_threadsafe(
|
||||||
hass.loop, async_say_hello, target).result()
|
hass.loop, async_say_hello, target).result()
|
||||||
|
|
||||||
async def async_say_hello(hass, target):
|
async def async_say_hello(hass, target):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user