Skip to content

Commit ac7daa0

Browse files
WebSocket: fix asyncio task not always stopping
1 parent 2d8a26b commit ac7daa0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

internal_filesystem/lib/websocket.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,10 @@ async def run_forever(
229229

230230
# Run the event loop in the main thread
231231
try:
232-
self._loop.run_until_complete(self._async_main())
232+
print("doing run_until_complete")
233+
#self._loop.run_until_complete(self._async_main()) # this doesn't always finish!
234+
asyncio.create_task(self._async_main())
235+
print("after run_until_complete")
233236
except KeyboardInterrupt:
234237
_log_debug("run_forever got KeyboardInterrupt")
235238
self.close()
@@ -272,7 +275,7 @@ async def _async_main(self):
272275
_log_error(f"_async_main's await self._connect_and_run() for {self.url} got exception: {e}")
273276
self.has_errored = True
274277
_run_callback(self.on_error, self, e)
275-
if not reconnect:
278+
if reconnect is not True:
276279
_log_debug("No reconnect configured, breaking loop")
277280
break
278281
_log_debug(f"Reconnecting after error in {reconnect}s")

0 commit comments

Comments
 (0)