Skip to content

Commit e61792a

Browse files
websocket.py: remove on_close() sleep
1 parent cd3aeb4 commit e61792a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

internal_filesystem/lib/websocket.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async def _process_callbacks_async():
7171
except IndexError:
7272
_log_debug("Callback queue empty")
7373
break
74-
await asyncio.sleep(0.5) # Yield to other tasks
74+
await asyncio.sleep(0.1) # Yield to other tasks
7575

7676
class WebSocketApp:
7777
def __init__(
@@ -281,8 +281,10 @@ async def _async_main(self):
281281

282282
# Cleanup
283283
_log_debug("Initiating cleanup")
284-
_run_callback(self.on_close, self, None, None)
285-
await asyncio.sleep(1) # wait a bit for _process_callbacks_async to call on_close
284+
#_run_callback(self.on_close, self, None, None)
285+
# await asyncio.sleep(0.1) # need to wait for _process_callbacks_async to call on_close, but how much is enough?
286+
if self.on_close:
287+
self.on_close(self, None, None) # don't use _run_callback() but do it immediately
286288
self.running = False
287289
callback_task.cancel() # Stop callback task
288290
try:

0 commit comments

Comments
 (0)