-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
If an exception occurs during the __init__ of the stream manager client (for example a bad port is passed or the server is temporarily down) the event loop thread gets leaked. Because the init never returns there is no client object to call close() on.
This can be reproduced with a simple script (assuming the server is not listening on port 1234)
import threading
from greengrasssdk.stream_manager import StreamManagerClient
while True:
threads = threading.enumerate()
print(f"Number of threads: {len(threads)}")
try:
client = StreamManagerClient(port=1234)
except Exception as e:
print(f"Exception: {e}")
which produces the following output:
Number of threads: 1
Connection error while connecting to server: [Errno 111] Connect call failed ('127.0.0.1', 1234)
Exception: [Errno 111] Connect call failed ('127.0.0.1', 1234)
Number of threads: 2
Connection error while connecting to server: [Errno 111] Connect call failed ('127.0.0.1', 1234)
Exception: [Errno 111] Connect call failed ('127.0.0.1', 1234)
Number of threads: 3
Connection error while connecting to server: [Errno 111] Connect call failed ('127.0.0.1', 1234)
Exception: [Errno 111] Connect call failed ('127.0.0.1', 1234)
...
Number of threads: 507
Connection error while connecting to server: [Errno 111] Connect call failed ('127.0.0.1', 1234)
Exception: [Errno 111] Connect call failed ('127.0.0.1', 1234)
Number of threads: 508
Exception: can't start new thread
Number of threads: 508
Exception: can't start new thread
Number of threads: 508
Exception: can't start new thread
This leads to the developer needing to manually find and kill the event loop thread.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels