try using existing event loop instead of creating a new one

This commit is contained in:
Josh Hawkins 2025-05-05 22:23:35 -05:00
parent 16274c1697
commit c76725bb38

View File

@ -48,7 +48,7 @@ class OnvifController:
self.ptz_metrics = ptz_metrics
# Create a dedicated event loop and run it in a separate thread
self.loop = asyncio.new_event_loop()
self.loop = asyncio.get_event_loop()
self.loop_thread = threading.Thread(target=self._run_event_loop, daemon=True)
self.loop_thread.start()
@ -63,7 +63,7 @@ class OnvifController:
def _run_event_loop(self) -> None:
"""Run the event loop in a separate thread."""
asyncio.set_event_loop(self.loop)
# asyncio.set_event_loop(self.loop)
try:
self.loop.run_forever()
except Exception as e: