errbotio / errbot

Errbot is a chatbot, a daemon that connects to your favorite chat service and bring your tools and some fun into the conversation.
http://errbot.io
GNU General Public License v3.0
3.13k stars 615 forks source link

fix: Close all ThreadPool on exit #1486

Closed e4r7hbug closed 3 years ago

e4r7hbug commented 3 years ago

This should fix the issues about bad file descriptors.

Exception ignored in: <function Pool.__del__ at 0x7ff2dd27d310>
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.9.0/x64/lib/python3.9/multiprocessing/pool.py", line 268, in __del__
    self._change_notifier.put(None)
  File "/opt/hostedtoolcache/Python/3.9.0/x64/lib/python3.9/multiprocessing/queues.py", line 378, in put
    self._writer.send_bytes(obj)
  File "/opt/hostedtoolcache/Python/3.9.0/x64/lib/python3.9/multiprocessing/connection.py", line 205, in send_bytes
    self._send_bytes(m[offset:offset + size])
  File "/opt/hostedtoolcache/Python/3.9.0/x64/lib/python3.9/multiprocessing/connection.py", line 416, in _send_bytes
    self._send(header + buf)
  File "/opt/hostedtoolcache/Python/3.9.0/x64/lib/python3.9/multiprocessing/connection.py", line 373, in _send
    n = write(self._handle, buf)
OSError: [Errno 9] Bad file descriptor

Or more accurately, unclosed pools when PYTHONWARNINGS=error.

Exception ignored in: <function Pool.__del__ at 0x7f5c952bcb80>
Traceback (most recent call last):
  File "/home/e4r7hbug/.pyenv/versions/3.9.0/lib/python3.9/multiprocessing/pool.py", line 265, in __del__
ResourceWarning: unclosed running multiprocessing pool <multiprocessing.pool.ThreadPool state=RUN pool_size=5>
sijis commented 3 years ago

Thanks you!