celery / django-celery-beat

Celery Periodic Tasks backed by the Django ORM
Other
1.69k stars 429 forks source link

Possible Breaking Change #668

Open neerajgoyal12 opened 1 year ago

neerajgoyal12 commented 1 year ago

Summary:

the command celery -A app worker -P eventlet -c 100 -l info --logfile=celery.log fails with latest django-celery-beat v 2.5.0

Include a brief description of the problem here, and fill out the version info below.

I have two conda environments. env A with following configuration:

python 3.10 celery 5.2.7 django 4.1.7 django-celery-beat 2.2.1 eventlet 0.33.3

env B with following configuration:

python 3.10 celery 5.3.1 django 4.2.3 django-celery-beat 2.5.0 eventlet 0.33.3

the command celery -A app worker -P eventlet -c 100 -l info --logfile=celery.log works well in env A

in env B fails with following log

(sample_app) neerajgoyal@Neerajs-MacBook-Pro app % celery -A app worker -P eventlet -c 100 -l info  --logfile=celery.log Traceback (most recent call last):   File "/Users/neerajgoyal/miniconda3/envs/sample_app/bin/celery", line 10, in <module>
    sys.exit(main())   File "/Users/neerajgoyal/miniconda3/envs/sample_app/lib/python3.10/site-packages/celery/__main__.py", line 13, in main
    maybe_patch_concurrency()   File "/Users/neerajgoyal/miniconda3/envs/sample_app/lib/python3.10/site-packages/celery/__init__.py", line 140, in maybe_patch_concurrency
    patcher()   File "/Users/neerajgoyal/miniconda3/envs/sample_app/lib/python3.10/site-packages/celery/__init__.py", line 101, in _patch_eventlet
    import eventlet.debug   File "/Users/neerajgoyal/miniconda3/envs/sample_app/lib/python3.10/site-packages/eventlet/__init__.py", line 17, in <module>
    from eventlet import convenience   File "/Users/neerajgoyal/miniconda3/envs/sample_app/lib/python3.10/site-packages/eventlet/convenience.py", line 7, in <module>
    from eventlet.green import socket   File "/Users/neerajgoyal/miniconda3/envs/sample_app/lib/python3.10/site-packages/eventlet/green/socket.py", line 21, in <module>
    from eventlet.support import greendns   File "/Users/neerajgoyal/miniconda3/envs/sample_app/lib/python3.10/site-packages/eventlet/support/greendns.py", line 79, in <module>
    setattr(dns, pkg, import_patched('dns.' + pkg))   File "/Users/neerajgoyal/miniconda3/envs/sample_app/lib/python3.10/site-packages/eventlet/support/greendns.py", line 61, in import_patched
    return patcher.import_patched(module_name, **modules)   File "/Users/neerajgoyal/miniconda3/envs/sample_app/lib/python3.10/site-packages/eventlet/patcher.py", line 132, in import_patched
    return inject(   File "/Users/neerajgoyal/miniconda3/envs/sample_app/lib/python3.10/site-packages/eventlet/patcher.py", line 109, in inject
    module = __import__(module_name, {}, {}, module_name.split('.')[:-1])   File "/Users/neerajgoyal/miniconda3/envs/sample_app/lib/python3.10/site-packages/dns/asyncquery.py", line 38, in <module>
    from dns.query import (   File "/Users/neerajgoyal/miniconda3/envs/sample_app/lib/python3.10/site-packages/dns/query.py", line 63, in <module>
    import httpcore   File "/Users/neerajgoyal/miniconda3/envs/sample_app/lib/python3.10/site-packages/httpcore/__init__.py", line 1, in <module>
    from ._api import request, stream   File "/Users/neerajgoyal/miniconda3/envs/sample_app/lib/python3.10/site-packages/httpcore/_api.py", line 5, in <module>
    from ._sync.connection_pool import ConnectionPool   File "/Users/neerajgoyal/miniconda3/envs/sample_app/lib/python3.10/site-packages/httpcore/_sync/__init__.py", line 1, in <module>
    from .connection import HTTPConnection   File "/Users/neerajgoyal/miniconda3/envs/sample_app/lib/python3.10/site-packages/httpcore/_sync/connection.py", line 12, in <module>
    from .._synchronization import Lock   File "/Users/neerajgoyal/miniconda3/envs/sample_app/lib/python3.10/site-packages/httpcore/_synchronization.py", line 13, in <module>
    import trio   File "/Users/neerajgoyal/miniconda3/envs/sample_app/lib/python3.10/site-packages/trio/__init__.py", line 19, in <module>
    from ._core import TASK_STATUS_IGNORED as TASK_STATUS_IGNORED  # isort: skip   File "/Users/neerajgoyal/miniconda3/envs/sample_app/lib/python3.10/site-packages/trio/_core/__init__.py", line 21, in <module>
    from ._local import RunVar   File "/Users/neerajgoyal/miniconda3/envs/sample_app/lib/python3.10/site-packages/trio/_core/_local.py", line 5, in <module>
    from . import _run   File "/Users/neerajgoyal/miniconda3/envs/sample_app/lib/python3.10/site-packages/trio/_core/_run.py", line 2548, in <module>

Stackoverflow Question Raised

Exact steps to reproduce the issue:

  1. Create a sample django project with celery and eventlet packages installed
  2. in the sample project installed apps add django-celery-beat and install the package
  3. try to fire celery worker with eventlet option

When you try to install the latest django-celery-beat in env B it would ask to downgrade importlib-metadata 6.8.0 to 4.13.0

Detailed information

My System is Apple Mac Book Pro, Apple M2, macOS 13.4.1 Ventura

auvipy commented 1 year ago

from . import _run File "/Users/neerajgoyal/miniconda3/envs/sample_app/lib/python3.10/site-packages/trio/_core/_run.py", line 2548, in

the traceback seem to be related to trio not celery.

neerajgoyal12 commented 1 year ago

trio was updated from 0.22.0 to 0.22.2 which seems a minor update and those particular lines in the code block is same in both the versions. It can be cause of

When you try to install the latest django-celery-beat in env B it would ask to downgrade importlib-metadata 6.8.0 to 4.13.0

neerajgoyal12 commented 1 year ago

When I install the 'django-celery-beat' v 2.2.1 in the env B it does not ask me to downgrade importlib-metadata but get error after starting celery beat with following error

model.last_run_at = self._default_now()
File "/Users/neerajgoyal/miniconda3/envs/zerodha-trading/lib/python3.10/site-packages/django_celery_beat/schedulers.py", line 143, in _default_now
now = now.tzinfo.localize(now.replace(tzinfo=None))
AttributeError
'zoneinfo.ZoneInfo' object has no attribute 'localize'

but at least the celery worker does get started successfully

neerajgoyal12 commented 1 year ago

Tried with gevent and prefork with django-celery-beat v 2.5.0 and its working