Read the Docs local install: Celery ValueError: signal only works in main thread

 ̄綄美尐妖づ 提交于 2021-01-28 05:25:45

问题


I have a local readthedocs install and get a ValueError exception when trying to import a project. I'm on release 5.1.0, running python 3.6 on Debian buster with celery 4.1.1 (from the requirements files).

From the debug.log:

[19/May/2020 23:31:11] celery.app.trace:124[24]: INFO Task readthedocs.projects.tasks.send_notifications[39551573-cfe1-46c1-b7e2-28bde20fd962] succeeded in 0.005342413205653429s: None
[19/May/2020 23:31:11] celery.app.trace:124[24]: INFO Task readthedocs.oauth.tasks.attach_webhook[119bed10-cacc-450c-bd51-822e96faffd7] succeeded in 0.016763793770223856s: False
[19/May/2020 23:31:11] celery.app.trace:249[24]: ERROR Task readthedocs.projects.tasks.update_docs_task[b6c22791-f1c6-4ddb-b64a-68d141580c30] raised unexpected: ValueError('signal only works in main thread',)
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/celery/app/trace.py", line 375, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/readthedocs.org/readthedocs/projects/tasks.py", line 448, in update_docs_task
    signal.signal(signal.SIGTERM, sigterm_received)
  File "/usr/local/lib/python3.6/signal.py", line 47, in signal
    handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread

I'm using manage.py runserver to run readthedocs, so I tried the --noreload option which has no effect, and the --nothreading option, which causes pages to hang forever.


回答1:


In order to get a local installation working you need to run a celery worker, which I wasn't doing before (and is not in the readthedocs docs). I'm using docker compose, and ran a separate service called celery that uses the same image as the main readthedocs service (custom docker image that installs django and readthedocs).

celery -A readthedocs.worker worker -E -l info -Q celery,web

Additionally, I have these settings in my Django config:

BROKER_URL = os.getenv('REDIS_URL')
CELERY_RESULT_BACKEND = os.getenv('REDIS_URL')
CELERY_ALWAYS_EAGER = False

I have a simple redis service in my compose config:

redis:
  image: redis

I then have REDIS_URL=redis://redis:6379/0 as an environment variable on my readthedocs and celery services.

Somewhat unrelated but I also stopped using python manage.py runserver and replaced it with uwsgi for production.

uwsgi \
    --http :80 \
    --wsgi-file readthedocs/wsgi.py \
    --static-map /static=./static \
    --master --processes 4 --threads 2



回答2:


I'm also facing same error when running builds in my local RTD instance.

[06/Jun/2020 07:13:50] celery.app.trace:249[91492]: ERROR Task readthedocs.projects.tasks.update_docs_task[e089a0bf-b275-4270-bd81-811bc414ef1a] raised unexpected: ValueError('signal only works in main thread',)

Can you please explain in detail what you've tried and succeeded in resolving the issue. I've read and followed the setup instructions from https://docs.readthedocs.io/en/stable/development/install.html Here there is no mention of docker-compose, so what is the significance of docker in setting up local RTD instance when I'm not using docker builder.



来源:https://stackoverflow.com/questions/61939886/read-the-docs-local-install-celery-valueerror-signal-only-works-in-main-thread

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!