use the builtin asyncio function run_coroutine_threadsafe (#210)

This asyncio util function is legacy from when we ran Python 3.4.
This commit is contained in:
carstenschroeder 2019-03-30 00:53:27 +01:00 committed by Paulus Schoutsen
parent f7ab181476
commit 17c6ca6c71

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.
```python
from homeassistant.util.async_ import run_coroutine_threadsafe
import asyncio
def say_hello(hass, target):
return run_coroutine_threadsafe(
return asyncio.run_coroutine_threadsafe(
async_say_hello(hass, target), hass.loop).result()
async def async_say_hello(hass, target):