Skip to content

Commit

Permalink
Create event loop only when necessary (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
rytilahti authored Sep 8, 2022
1 parent abe4208 commit 9461b0b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion eq3bt/bleakconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ def __init__(self, mac, iface):
self._callbacks = {}
self._notifyevent = asyncio.Event()
self._notification_handle = None
self._loop = asyncio.new_event_loop()

try:
self._loop = asyncio.get_running_loop()
except RuntimeError:
self._loop = asyncio.new_event_loop()
asyncio.set_event_loop(self._loop)

def __enter__(self):
"""
Expand Down

0 comments on commit 9461b0b

Please sign in to comment.