Use correct method to run coroutines threadsafe

This commit is contained in:
Paulus Schoutsen 2018-09-15 17:56:21 +02:00 committed by GitHub
parent 6041e8382f
commit b13c07bad4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -74,10 +74,10 @@ Sometimes it will happen that youre 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):