You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PeriodicTask that have a expire_seconds defined won't have a expires option set when the task is dispatched by the admin action "Run Selected Tasks"
Celery Version: 5.4.0
Celery-Beat Version: 2.6.0
Exact steps to reproduce the issue:
Create a PeriodicTask entry with expire_seconds
Run the task via the admin
Try to get the task.request.expires option, it will return None
Detailed information
The expire_seconds option is only applied when the celery is applied from the celery beat process.
In my case, receiving the expires option is crucial to know when the task was queued.
More information about my setup that may help to reproduce the error.
# custom_task.pyfromdatetimeimportdatetimefromdatetimeimporttimedeltafromceleryimportTaskclassScheduledAtAwareTask(Task):
@propertydefscheduled_at(self) ->datetime:
"""The exact time that this task was sent to the queue, this means that this task can be retried and this time will always be the same"""ifnotself.request.expires:
raiseValueError(
"Missing `expires` option, this task was not scheduled or the `expires`",
"option was not given on BEAT_SCHEDULE",
)
# The amount of miliseconds this task will take to expire, with this, we can go back in time# per-task basis, because each task can be set with different expires timestask_expiration=int(self.request.properties["expiration"]) /1000dt=datetime.fromisoformat(self.request.expires).astimezone()
returndt-timedelta(seconds=task_expiration)
# tasks.pyfromceleryimportshared_taskfromcustom_taskimportScheduledAtAwareTask@shared_task(bind=True)defexample_task(self: ScheduledAtAwareTask):
self.scheduled_at# raises ValueError
The text was updated successfully, but these errors were encountered:
Summary:
PeriodicTask that have a
expire_seconds
defined won't have aexpires
option set when the task is dispatched by the admin action "Run Selected Tasks"Exact steps to reproduce the issue:
PeriodicTask
entry with expire_secondstask.request.expires
option, it will returnNone
Detailed information
The
expire_seconds
option is only applied when the celery is applied from the celery beat process.In my case, receiving the expires option is crucial to know when the task was queued.
More information about my setup that may help to reproduce the error.
The text was updated successfully, but these errors were encountered: