Max retry exceeded handling

Issue #5 resolved
Olivier Girardot
created an issue

hi back, opening another ticket to talk about the max_retry exceeded error seen in the log.

Doesn't the catch clause here allows the celery task to end up correctly even if max_retries are reached ? :

https://bitbucket.org/pmclanahan/django-celery-email/src/6c99f9577020/djcelery_email/tasks.py#cl-31

Comments (2)

  1. Olivier Girardot reporter

    Hi back, just tested the new release the task is accurately defined as failed (btw i'm still working on making it work with amazon SES lol) but the logs are maybe a little bit "violent" :

    [...: INFO/MainProcess] Got task from broker: djcelery_email_send[07cec7a0-d456-4d7b-9644-50071e38ada4]
    [...: ERROR/PoolWorker-3] 400 Bad Request
    [...: ERROR/PoolWorker-3] <ErrorResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/">
      <Error>
        <Type>Sender</Type>
        <Code>MessageRejected</Code>
        <Message>Email address is not verified.</Message>
      </Error>
      <RequestId>4ce92a26-f04a-11e0-a0c6-bd0cd6889f6b</RequestId>
    </ErrorResponse>
    
    [...: WARNING/PoolWorker-3] djcelery_email_send[07cec7a0-d456-4d7b-9644-50071e38ada4]: Failed to send email message to [u'xxx@xxx.com'], retrying.
    [...: INFO/MainProcess] Got task from broker: djcelery_email_send[07cec7a0-d456-4d7b-9644-50071e38ada4] eta:[2011-10-06 13:40:53.320573]
    [...: INFO/MainProcess] Task djcelery_email_send[07cec7a0-d456-4d7b-9644-50071e38ada4] retry: None
    [...: WARNING/PoolWorker-1] djcelery_email_send[07cec7a0-d456-4d7b-9644-50071e38ada4]: Failed to send email message to [u'xxx@xxx.com'], retrying.
    [...: INFO/MainProcess] Got task from broker: djcelery_email_send[07cec7a0-d456-4d7b-9644-50071e38ada4] eta:[2011-10-06 13:43:53.652604]
    [...: INFO/MainProcess] Task djcelery_email_send[07cec7a0-d456-4d7b-9644-50071e38ada4] retry: None
    [...: WARNING/PoolWorker-4] djcelery_email_send[07cec7a0-d456-4d7b-9644-50071e38ada4]: Failed to send email message to [u'xxx@xxx.com'], retrying.
    [...: INFO/MainProcess] Got task from broker: djcelery_email_send[07cec7a0-d456-4d7b-9644-50071e38ada4] eta:[2011-10-06 13:46:53.935653]
    [...: INFO/MainProcess] Task djcelery_email_send[07cec7a0-d456-4d7b-9644-50071e38ada4] retry: None
    [...: WARNING/PoolWorker-2] djcelery_email_send[07cec7a0-d456-4d7b-9644-50071e38ada4]: Failed to send email message to [u'xxx@xxx.com'], retrying.
    
    
    [...: ERROR/MainProcess] Task djcelery_email_send[07cec7a0-d456-4d7b-9644-50071e38ada4] raised exception: BadHeaderError('Header values can\'t contain newlines (got u\'<ErrorResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/">\\n  <Error>\\n    <Type>Sender</Type>\\n    <Code>MessageRejected</Code>\\n    <Message>Email address is not verified.</Message>\\n  </Error>\\n  <RequestId>4ce92a26-f04a-11e0-a0c6-bd0cd6889f6b</RequestId>\\n</ErrorResponse>\\n\' for header \'body\')',)
    Traceback (most recent call last):
      File "/Users/ogirardot/Documents/Python/virtualenv/appartinfo/lib/python2.6/site-packages/celery/execute/trace.py", line 36, in trace
        return cls(states.SUCCESS, retval=fun(*args, **kwargs))
      File "/Users/ogirardot/Documents/Python/virtualenv/appartinfo/lib/python2.6/site-packages/celery/app/task/__init__.py", line 232, in __call__
        return self.run(*args, **kwargs)
      File "/Users/ogirardot/Documents/Python/virtualenv/appartinfo/lib/python2.6/site-packages/celery/app/__init__.py", line 172, in run
        return fun(*args, **kwargs)
      File "/Users/ogirardot/Documents/Python/virtualenv/appartinfo/lib/python2.6/site-packages/djcelery_email/tasks.py", line 29, in send_email
        send_email.retry(exc=e)
      File "/Users/ogirardot/Documents/Python/virtualenv/appartinfo/lib/python2.6/site-packages/celery/app/task/__init__.py", line 520, in retry
        self.name, options["task_id"], args, kwargs))
    BadHeaderError: Header values can't contain newlines (got u'<ErrorResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/">\n  <Error>\n    <Type>Sender</Type>\n    <Code>MessageRejected</Code>\n    <Message>Email address is not verified.</Message>\n  </Error>\n  <RequestId>4ce92a26-f04a-11e0-a0c6-bd0cd6889f6b</RequestId>\n</ErrorResponse>\n' for header 'body')
    
    None
    

    I figure the "None" of the end is the return of the task itself, but the whole stacktrace seems a little scary, and i don't understand exactly what is happening, it seems the error message was passed as an( email ?) header, the error being raised here : https://github.com/ask/celery/blob/master/celery/app/task/__init__.py#L522

    Well mission's complete :), thank you for your help, at least there won't be any misunderstanding and i won't lost any "uncompleted" task. i'll update #4 when completed and do a blogpost for the full steps. regards,

    Olivier.

  2. Log in to comment