cronitor-python
cronitor-python copied to clipboard
Failure to register jobs at startup
Hello! I'm having the following issue where cronitor-python is attempting to inject headers into tasks on startup, but it's failing to look up tasks in the registry:
Starting ...
Booting API server
Settings module: redacted
Log level: INFO
Debug: False
celery beat v5.3.6 (emerald-rush) is starting.
__ - ... __ - _
LocalTime -> 2024-05-17 16:38:54
Configuration ->
. broker -> redacted
. loader -> celery.loaders.app.AppLoader
. scheduler -> django_celery_beat.schedulers.DatabaseScheduler
. logfile -> [stderr]@%INFO
. maxinterval -> 5.00 seconds (5s)
[2024-05-17 16:38:54,186: INFO/MainProcess] beat: Starting...
[2024-05-17 16:38:54,808: INFO/MainProcess] DatabaseScheduler: Schedule changed.
[2024-05-17 16:38:54,815: ERROR/MainProcess] Signal handler <function celerybeat_startup at 0x7efdb990cf40> raised: AttributeError("'NoneType' object has no attribute 's'")
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/celery/utils/dispatch/signal.py", line 276, in send
response = receiver(signal=self, sender=sender, **named)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/cronitor/celery.py", line 113, in celerybeat_startup
app.tasks.get(entry.task).s().set(headers=headers),
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 's'
[2024-05-17 16:38:55,125: INFO/MainProcess] DatabaseScheduler: Schedule changed.
This is causing it not to register schedules for tasks on celery startup (though actual task executions are being captured)
Hi Nick,
Thanks for opening this. I believe the cause of this is that you're trying to run the discover command while using the django_celery_beat scheduler, which unfortunately is not supported.
It should, at a minimum, raise a better error message, however I'd love to support this better for other Djang/Celery devs. We would welcome a pull request!