You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Important Save a reference to the result of this function, to avoid a task disappearing mid-execution. The event loop only keeps weak references to tasks. A task that isn’t referenced elsewhere may get garbage collected at any time, even before it’s done. For reliable “fire-and-forget” background tasks, gather them in a collection:
The text was updated successfully, but these errors were encountered:
As noted in the Python docs, a reference to the return value of
`asyncio.ensure_future()` must be held in order to prevent it from
being garbage collected before the task completes.
This applies the recommended fix from the docs of holding the reference
in a global set and then discarding the reference when the task
completes.
Also change `asyncio.ensure_future()` to `asyncio.create_task()` while
we are touching this since the minimum supported Python version is now
3.7.
Fixes: #1258
As noted in the Python docs, a reference to the return value of
`asyncio.ensure_future()` must be held in order to prevent it from
being garbage collected before the task completes.
This applies the recommended fix from the docs of holding the reference
in a global set and then discarding the reference when the task
completes.
Also change `asyncio.ensure_future()` to `asyncio.create_task()` while
we are touching this since the minimum supported Python version is now
3.7.
Fixes: #1258
bleak/bleak/backends/bluezdbus/client.py
Line 246 in 1b93859
nothing is holding a reference to the task and asyncio tasks are tracked in weakset which means the task can get garbage collected before it finishes
Sorry I didn't point this out before. I only noticed when reviewing the 0.20 changes for HA compatibility
https://docs.python.org/3/library/asyncio-task.html#creating-tasks
From the asyncio tasks section:
The text was updated successfully, but these errors were encountered: