-
-
Notifications
You must be signed in to change notification settings - Fork 578
Closed
Labels
Description
Closing sync ServerConnection from server side, before consuming all data results in deadlocked threads started by websockets, preventing the program from exiting. I have attached (main.py.txt) a minimal example with a client and a server that consistently results in the problem. It is stuck on self.messages_fetched.wait() in Assembler.put() and on self.recv_events_thread.join() in Connection.send_context().
It also provides a switch to use the asyncio based websockets server instead, which doesn't suffer from the issue. Here is a run on latest main with hash bb17be2.
This is the threads from websockets at the end of the execution, also printed by the script:
Thread 0x00007f3cecabb640 (most recent call first):
File "/usr/lib/python3.10/threading.py", line 320 in wait
File "/usr/lib/python3.10/threading.py", line 607 in wait
File "/home/mandermo/develop/bsh/websockets/src/websockets/sync/messages.py", line 245 in put
File "/home/mandermo/develop/bsh/websockets/src/websockets/sync/connection.py", line 485 in process_event
File "/home/mandermo/develop/bsh/websockets/src/websockets/sync/server.py", line 160 in process_event
File "/home/mandermo/develop/bsh/websockets/src/websockets/sync/connection.py", line 579 in recv_events
File "/home/mandermo/develop/bsh/websockets/src/websockets/sync/server.py", line 168 in recv_events
File "/usr/lib/python3.10/threading.py", line 953 in run
File "/usr/lib/python3.10/threading.py", line 1016 in _bootstrap_inner
File "/usr/lib/python3.10/threading.py", line 973 in _bootstrap
Thread 0x00007f3ced2bc640 (most recent call first):
File "/usr/lib/python3.10/threading.py", line 1116 in _wait_for_tstate_lock
File "/usr/lib/python3.10/threading.py", line 1096 in join
File "/home/mandermo/develop/bsh/websockets/src/websockets/sync/connection.py", line 712 in send_context
File "/usr/lib/python3.10/contextlib.py", line 142 in __exit__
File "/home/mandermo/develop/bsh/websockets/src/websockets/sync/connection.py", line 399 in close
File "/home/mandermo/develop/bsh/websockets/src/websockets/sync/server.py", line 498 in conn_handler
File "/usr/lib/python3.10/threading.py", line 953 in run
File "/usr/lib/python3.10/threading.py", line 1016 in _bootstrap_inner
File "/usr/lib/python3.10/threading.py", line 973 in _bootstrap