Store strong references to async tasks

Reason: https://news.t0.vc/IEUC
This commit is contained in:
Tanner Collin 2023-02-12 18:37:41 +00:00
parent 47cdfff327
commit 43535d0a95

View File

@ -468,8 +468,8 @@ if __name__ == '__main__':
sensors.add(SolarSensor('solar', 'Solar')) sensors.add(SolarSensor('solar', 'Solar'))
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
loop.create_task(poll_sensors()).add_done_callback(task_died) a = loop.create_task(poll_sensors()).add_done_callback(task_died)
loop.create_task(fetch_mqtt()).add_done_callback(task_died) b = loop.create_task(fetch_mqtt()).add_done_callback(task_died)
loop.create_task(run_webserver()).add_done_callback(task_died) c = loop.create_task(run_webserver()).add_done_callback(task_died)
loop.run_forever() loop.run_forever()