Skip to content

Wrong number of arguments in _signal_handler() #26

@igogold

Description

@igogold

When I send Ctrl+C / SIGTERM to running bot script I got such errors (signal should be send twice to completely exit):

Traceback (most recent call last):
  File "/usr/local/bin/icqbot.py", line 510, in <module>
    main()
  File "/usr/local/bin/icqbot.py", line 87, in main
    run_service()
  File "/usr/local/bin/icqbot.py", line 121, in run_service
    bot.idle()
  File "/usr/local/lib/python-venv/icqbot/lib/python3.7/site-packages/bot/bot.py", line 155, in idle
    sleep(1)
TypeError: _signal_handler() takes 2 positional arguments but 3 were given
Exception ignored in: <module 'threading' from '/usr/lib/python3.7/threading.py'>
Traceback (most recent call last):
  File "/usr/lib/python3.7/threading.py", line 1281, in _shutdown
    t.join()
  File "/usr/lib/python3.7/threading.py", line 1032, in join
    self._wait_for_tstate_lock()
  File "/usr/lib/python3.7/threading.py", line 1048, in _wait_for_tstate_lock
    elif lock.acquire(block, timeout):
TypeError: _signal_handler() takes 2 positional arguments but 3 were given

I think error because of

signal.signal(signalnum, handler)
The handler is called with two arguments: the signal number and the current stack frame (None or a frame object; for a description of frame objects, see the description in the type hierarchy or see the attribute descriptions in the inspect module).

but _signal_handler() want to get only one argument (after self), not two.

def _signal_handler(self, sig: int):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions