rq-dashboard icon indicating copy to clipboard operation
rq-dashboard copied to clipboard

Signal Error when UnixSignalDeathPenalty is triggered

Open jackzzs opened this issue 10 months ago • 1 comments

Describe the bug Error occurs and some page can not be loaded:

File ".../site-packages/flask/app.py", line 1463, in wsgi_app
    response = self.full_dispatch_request()
  File ".../site-packages/flask/app.py", line 872, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File ".../site-packages/flask/app.py", line 870, in full_dispatch_request
    rv = self.dispatch_request()
  File ".../site-packages/flask/app.py", line 855, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
  File ".../site-packages/rq_dashboard/web.py", line 111, in _wrapped
    result_dict = f(*args, **kwargs)
  File ".../site-packages/rq_dashboard/web.py", line 460, in list_queues
    queues = serialize_queues(instance_number, sorted(Queue.all()))
  File ".../site-packages/rq_dashboard/web.py", line 118, in serialize_queues
    return [
  File ".../site-packages/rq_dashboard/web.py", line 139, in <listcomp>
    started_job_registry_count=StartedJobRegistry(q.name).count,
  File ".../site-packages/rq/registry.py", line 89, in count
    self.cleanup()
  File ".../site-packages/rq/registry.py", line 238, in cleanup
    job.execute_failure_callback(
  File ".../site-packages/rq/job.py", line 1430, in execute_failure_callback
    with death_penalty_class(self.failure_callback_timeout, JobTimeoutException, job_id=self.id):
  File ".../site-packages/rq/timeouts.py", line 36, in __enter__
    self.setup_death_penalty()
  File ".../site-packages/rq/timeouts.py", line 69, in setup_death_penalty
    signal.signal(signal.SIGALRM, self.handle_death_penalty)
  File ".../signal.py", line 47, in signal
    handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread

To Reproduce Steps to reproduce the behavior:

  1. Send a rq task which is stopped due to timeout.
  2. Do not try to load the status of this task.
  3. Start rq-dashboard.
  4. See error.

Expected behavior No error.

Screenshots If applicable, add screenshots to help explain your problem. image

Additional context

  • OS: [e.g. iOS]
  • Python Version [e.g. 3.7.3]

Add any other context about the problem here.

jackzzs avatar Apr 11 '24 02:04 jackzzs