Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Unhandled exceptions emerging from orphan threads on server #139

Open
3manifold opened this issue Nov 12, 2024 · 0 comments · May be fixed by #138
Open

[Bug] Unhandled exceptions emerging from orphan threads on server #139

3manifold opened this issue Nov 12, 2024 · 0 comments · May be fixed by #138

Comments

@3manifold
Copy link
Contributor

3manifold commented Nov 12, 2024

Description

As soon as the server starts, the main thread runs and exits immediately (main call) leaving the child threads (handlers) running in an orphan state.

This can have several consequences, including resource leakage (orphan threads may continue to consume system resources, leading to potential performance degradation) and unpredictable behavior (the behavior of orphan threads can be unpredictable since they are no longer under the control of their parent). In specific, one of the issues can be unhandled thread exceptions, as demonstrated in the section that follows.

Reproduce

Run locally:

  1. python3 s2s_pipeline.py --recv_host 0.0.0.0 --send_host 0.0.0.0 # wait for server to start..
  2. python3 listen_and_play.py
  3. kill -2 <server_PID> # send KeyboardInterrupt to server
  4. # Press Enter in client session to terminate client
  5. # Exception message is shown in the server session

The script above will cause the following error:

....
... - connections.socket_sender - INFO - Sender waiting to be connected...
... - connections.socket_receiver - INFO - receiver connected
... - connections.socket_sender - INFO - sender connected
Exception ignored in: <module 'threading' from '/usr/lib/python3.10/threading.py'>
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1567, in _shutdown
    lock.acquire()
KeyboardInterrupt: 

Implementation as well as a description of the fix can be found in pull request #138 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant