Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signal Error when UnixSignalDeathPenalty is triggered #486

Open
jackzzs opened this issue Apr 11, 2024 · 1 comment
Open

Signal Error when UnixSignalDeathPenalty is triggered #486

jackzzs opened this issue Apr 11, 2024 · 1 comment

Comments

@jackzzs
Copy link

jackzzs commented Apr 11, 2024

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.

@rbange
Copy link

rbange commented Jun 21, 2024

Getting a similar error:

Exception on /dashboard/0/data/jobs/multi_optimization/started/8/1.json [GET]
Traceback (most recent call last):
  File "/venv/lib/python3.12/site-packages/flask/app.py", line 1473, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/flask/app.py", line 882, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/flask/app.py", line 865, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/rq_dashboard/web.py", line 112, in _wrapped
    result_dict = f(*args, **kwargs)
                  ^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/rq_dashboard/web.py", line 491, in list_jobs
    total_items, jobs = get_queue_registry_jobs_count(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/rq_dashboard/web.py", line 270, in get_queue_registry_jobs_count
    total_items = current_queue.count
                  ^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/rq/registry.py", line 89, in count
    self.cleanup()
  File "/venv/lib/python3.12/site-packages/rq/registry.py", line 238, in cleanup
    job.execute_failure_callback(
  File "/venv/lib/python3.12/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 "/venv/lib/python3.12/site-packages/rq/timeouts.py", line 36, in __enter__
    self.setup_death_penalty()
  File "/venv/lib/python3.12/site-packages/rq/timeouts.py", line 69, in setup_death_penalty
    signal.signal(signal.SIGALRM, self.handle_death_penalty)
  File "/usr/local/lib/python3.12/signal.py", line 58, in signal
    handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: signal only works in main thread of the main interpreter

The dashboard is run in a Kubernetes container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants