Skip to content

Commit 6b4822b

Browse files
authored
handle running loop better (#14)
* handle running loop better * formatting
1 parent d5c9953 commit 6b4822b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

openevsehttp/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
ERROR_UNKNOWN = "Unknown"
4141
ERROR_TIMEOUT = "Timeout while updating "
4242

43+
LOOP_INFO = "Event loop already running, not creating new one."
44+
4345
MAX_FAILED_ATTEMPTS = 5
4446

4547
SIGNAL_CONNECTION_STATE = "websocket_state"
@@ -270,7 +272,10 @@ def _start_listening(self):
270272
self._loop.create_task(self.websocket.listen())
271273
pending = asyncio.all_tasks()
272274
self._ws_listening = True
273-
self._loop.run_until_complete(asyncio.gather(*pending))
275+
try:
276+
self._loop.run_until_complete(asyncio.gather(*pending))
277+
except RuntimeError:
278+
_LOGGER.info(LOOP_INFO)
274279

275280
def _update_status(self, msgtype, data, error):
276281
"""Update data from websocket listener."""

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
PROJECT_DIR = Path(__file__).parent.resolve()
77
README_FILE = PROJECT_DIR / "README.md"
8-
VERSION = "0.1.11"
8+
VERSION = "0.1.12"
99

1010

1111
setup(

0 commit comments

Comments
 (0)