Celery: Tasks with expires fail with AttributeError("'str' object has no attribute 'isoformat'",)

Created on 12 Jun 2017  Â·  3Comments  Â·  Source: celery/celery

Checklist

  • [x] I have included the output of celery -A proj report in the issue.
    (if you are not able to do this, then at least specify the Celery
    version affected).
software -> celery:4.0.2 (latentcall) kombu:4.0.2 py:3.6.1
            billiard:3.5.0.2 py-amqp:2.1.4
platform -> system:Darwin arch:64bit imp:CPython
loader   -> celery.loaders.default.Loader
settings -> transport:amqp results:disabled

Steps to reproduce

  1. Create a task that retries via raise self.retry()
  2. Call the task with send_task and set expires

Expected behavior

The task should retry until the expires time is hit or the max_retries value is hit

Actual behavior

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/celery/app/task.py", line 684, in retry
    S.apply_async()
  File "/usr/lib/python3.6/site-packages/celery/canvas.py", line 221, in apply_async
    return _apply(args, kwargs, **options)
  File "/usr/lib/python3.6/site-packages/celery/app/task.py", line 535, in apply_async
    **options
  File "/usr/lib/python3.6/site-packages/celery/app/base.py", line 729, in send_task
    root_id, parent_id, shadow, chain,
  File "/usr/lib/python3.6/site-packages/celery/app/amqp.py", line 334, in as_task_v2
    expires = expires and expires.isoformat()
AttributeError: 'str' object has no attribute 'isoformat'
Bug Report Duplicate ✘ Has Testcase ✔

Most helpful comment

A workaround that appears to fix the issue - reassigning the value of self.request.expires before raising self.retry().

I.e., in the run method:

self.request.expires = dateparser.parse(self.request.expires)
raise self.retry()

All 3 comments

A workaround that appears to fix the issue - reassigning the value of self.request.expires before raising self.retry().

I.e., in the run method:

self.request.expires = dateparser.parse(self.request.expires)
raise self.retry()

probably this is fixed and we can close it? @thedrow

Looks like a duplicate.
Please try the latest RC and see if the problem is resolved.
If it isn't, comment here and we'll reopen.

Was this page helpful?
0 / 5 - 0 ratings