Merged
Conversation
From the mp documentation: https://docs.python.org/3/library/multiprocessing.html#multiprocessing.pool.ThreadPool > resources must also be properly managed, either by using the pool as a context manager or by calling close() and terminate() manually. Without explicit close() or terminate() it can produce exceptions on exit when __del__ is called, before the fds were opened: Exception ignored while calling deallocator <function Pool.__del__ at 0x10a340bf0>: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/multiprocessing/pool.py", line 271, in __del__ self._change_notifier.put(None) File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/multiprocessing/queues.py", line 397, in put self._writer.send_bytes(obj) File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/multiprocessing/connection.py", line 206, in send_bytes self._send_bytes(m[offset:offset + size]) File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/multiprocessing/connection.py", line 444, in _send_bytes self._send(header + buf) File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/multiprocessing/connection.py", line 400, in _send n = write(self._handle, buf) OSError: [Errno 9] Bad file descriptor Much cleaner would be to a use context manager but BaseNetboxClient does not provide one, instead doing init_pool in the constructor. This leaves atexit as a least involved option to prevent this annoying traceback on the shutdown.
Tishka17
approved these changes
Jan 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
From the mp.ThreadPool documentation.
Without explicit close() or terminate() it can produce exceptions on exit when
__del__is called, before the fds were opened:Much cleaner would be to a use context manager but BaseNetboxClient does not provide one, instead doing init_pool in the constructor. This leaves atexit as a least involved option to prevent this annoying traceback on the shutdown.