ikalchev / HAP-python

A python implementation of the HomeKit Accessory Protocol (HAP)
Other
607 stars 116 forks source link

Ensure tasks are not garbage collected before they finish #460

Closed bdraco closed 8 months ago

bdraco commented 8 months ago

https://docs.python.org/3/library/asyncio-task.html#asyncio.create_task

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:

codecov[bot] commented 8 months ago

Codecov Report

Merging #460 (fc26d89) into dev (d9243b6) will increase coverage by 0.02%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##              dev     #460      +/-   ##
==========================================
+ Coverage   92.26%   92.29%   +0.02%     
==========================================
  Files          20       20              
  Lines        2198     2206       +8     
  Branches      278      278              
==========================================
+ Hits         2028     2036       +8     
  Misses        124      124              
  Partials       46       46              
Files Coverage Δ
pyhap/accessory_driver.py 91.66% <100.00%> (ø)
pyhap/hap_protocol.py 99.38% <100.00%> (+<0.01%) :arrow_up:
pyhap/util.py 92.68% <100.00%> (+0.68%) :arrow_up: