mirror of
https://github.com/home-assistant/developers.home-assistant.git
synced 2025-07-07 17:36:29 +00:00
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:
parent
f7ab181476
commit
17c6ca6c71
@ -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.
|
||||
|
||||
```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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user