Skip to content

Commit 061d28f

Browse files
committed
only start a loop if it's not running
1 parent 677574d commit 061d28f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

openevsehttp/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,11 @@ async def update(self) -> None:
231231

232232
def _start_listening(self):
233233
"""Start the websocket listener."""
234-
self._loop.create_task(self.websocket.listen())
235-
pending = asyncio.all_tasks()
236-
self._loop.run_until_complete(asyncio.gather(*pending))
237-
self._ws_listening = True
234+
if not self._loop.is_running():
235+
self._loop.create_task(self.websocket.listen())
236+
pending = asyncio.all_tasks()
237+
self._loop.run_until_complete(asyncio.gather(*pending))
238+
self._ws_listening = True
238239

239240
def _update_status(self, msgtype, data, error):
240241
"""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.8-13"
8+
VERSION = "0.1.8-14"
99

1010

1111
setup(

0 commit comments

Comments
 (0)