sigterm_handler() takes 0 positional arguments but 2 were given

I have a process running with the command psutil.popen. I'm not sure the if this has something to do with that but this is the error I am getting. 

Error loading: /snap/pycharm-professional/206/plugins/python/helpers/pydev/pydevd_attach_to_process/attach_linux_amd64.so
Process ForkPoolWorker-10:
Traceback (most recent call last):
File "/usr/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
self.run()
File "/usr/lib/python3.7/multiprocessing/process.py", line 99, in run
self._target(*self._args, **self._kwargs)
File "/usr/lib/python3.7/multiprocessing/pool.py", line 110, in worker
task = get()
File "/usr/lib/python3.7/multiprocessing/queues.py", line 351, in get
with self._rlock:
File "/usr/lib/python3.7/multiprocessing/synchronize.py", line 95, in __enter__
return self._semlock.__enter__()
TypeError: sigterm_handler() takes 0 positional arguments but 2 were given

And in debug mode, traceback reaches back to this line of code:

with get_context("fork").Pool(2) as p:

And the traceback is:

File "/usr/lib/python3.7/multiprocessing/context.py", line 119, in Pool
context=self.get_context())
File "/usr/lib/python3.7/multiprocessing/pool.py", line 176, in __init__
self._repopulate_pool()
File "/usr/lib/python3.7/multiprocessing/pool.py", line 241, in _repopulate_pool
w.start()
File "/usr/lib/python3.7/multiprocessing/process.py", line 112, in start
self._popen = self._Popen(self)
File "/usr/lib/python3.7/multiprocessing/context.py", line 277, in _Popen
return Popen(process_obj)
File "/usr/lib/python3.7/multiprocessing/popen_fork.py", line 20, in __init__
self._launch(process_obj)
File "/usr/lib/python3.7/multiprocessing/popen_fork.py", line 70, in _launch
self.pid = os.fork()
File "/snap/pycharm-professional/206/plugins/python/helpers/pydev/_pydev_bundle/pydev_monkey.py", line 613, in new_fork
_on_forked_process()
File "/snap/pycharm-professional/206/plugins/python/helpers/pydev/_pydev_bundle/pydev_monkey.py", line 74, in _on_forked_process
pydevd.settrace_forked()
File "/snap/pycharm-professional/206/plugins/python/helpers/pydev/pydevd.py", line 1871, in settrace_forked
patch_multiprocessing=True,
File "/snap/pycharm-professional/206/plugins/python/helpers/pydev/pydevd.py", line 1635, in settrace
stop_at_frame,
File "/snap/pycharm-professional/206/plugins/python/helpers/pydev/pydevd.py", line 1715, in _locked_settrace
debugger.enable_tracing(apply_to_all_threads=True)
File "/snap/pycharm-professional/206/plugins/python/helpers/pydev/pydevd.py", line 486, in enable_tracing
pydevd_tracing.set_trace_to_threads(self.dummy_trace_dispatch)
File "/snap/pycharm-professional/206/plugins/python/helpers/pydev/pydevd_tracing.py", line 175, in set_trace_to_threads
thread_idents = set(sys._current_frames().keys())
TypeError: sigterm_handler() takes 0 positional arguments but 2 were given

On the other hand, if I "spawn" instead of "fork", I don't encounter any kind of error... This works:

with get_context("spawn").Pool(2) as p:

I'm on Ubuntu 20.02 LTS but I had the same issue on Ubuntu 18.02 and 19.10.

Please sign in to leave a comment.