use running loop if possible

This commit is contained in:
Jack Robison 2018-10-08 17:44:11 -04:00
parent e6fbab30aa
commit 79fb296a6e
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -219,8 +219,11 @@ class UPnP:
kwargs: dict = None) -> None: kwargs: dict = None) -> None:
kwargs = kwargs or {} kwargs = kwargs or {}
loop = asyncio.new_event_loop() try:
asyncio.set_event_loop(loop) asyncio.get_running_loop()
except RuntimeError:
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
fut: asyncio.Future = asyncio.Future() fut: asyncio.Future = asyncio.Future()