UnicodeEncodeError, if the exception message contains unicode characters
The exception raised in one of my tasks had unicode characters as shown below. Due to this i didn't receive an error mail.
It will be great if there is a way to get General celery error mails rather than just Task error mails.
Traceback (most recent call last):
File "~/python2.7/site-packages/billiard/pool.py", line 1696, in safe_apply_callback
fun(*args, **kwargs)
File "~/python2.7/site-packages/celery/worker/job.py", line 383, in on_success
return self.on_failure(ret_value)
File "~/python2.7/site-packages/celery/worker/job.py", line 442, in on_failure
self._log_error(exc_info, send_failed_event=send_failed_event)
File "~/python2.7/site-packages/celery/worker/job.py", line 513, in _log_error
task.send_error_email(context, einfo.exception)
File "~/python2.7/site-packages/celery/app/task.py", line 881, in send_error_email
self.ErrorMail(self, **kwargs).send(context, exc)
File "~/python2.7/site-packages/celery/utils/mail.py", line 189, in send
self.format_body(context),
File "~/python2.7/site-packages/celery/utils/mail.py", line 184, in format_body
return self.body.strip().format(**context)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 2897-2899: ordinal not in range(128)
#1896 This has been reported here before, but no traceback shared.
Can #2651 fix this?
Same problem here on Celery 3.1.18
Traceback (most recent call last):
File "python2.7/site-packages/billiard/pool.py", line 1696, in safe_apply_callback
fun(*args, **kwargs)
File "python2.7/site-packages/celery/worker/job.py", line 383, in on_success
return self.on_failure(ret_value)
File "python2.7/site-packages/celery/worker/job.py", line 442, in on_failure
self._log_error(exc_info, send_failed_event=send_failed_event)
File "python2.7/site-packages/celery/worker/job.py", line 513, in _log_error
task.send_error_email(context, einfo.exception)
File "python2.7/site-packages/celery/app/task.py", line 881, in send_error_email
self.ErrorMail(self, **kwargs).send(context, exc)
File "python2.7/site-packages/celery/utils/mail.py", line 189, in send
self.format_body(context),
File "python2.7/site-packages/celery/utils/mail.py", line 184, in format_body
return self.body.strip().format(**context)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xed' in position 3531: ordinal not in range(128)
*) Same problem without setting EMAIL_CHARSET = 'utf-8'
Give me a little time to investigate if the new setting has an effect... need to trigger the same email.
Using celery 3.1.19 with Django here and still have the same problem - which is kind of annoying. Did this commit made it into 3.1.19 ? Because grepping for EMAIL_CHARSET in my install doesn't show anything...
It was merged into 4.0 dev, not 3.1, but setting the charset to utf-8 by default seems sane to me.
Any chance to get this backported to the 3.1.x branch ?
+1. Is this bug can be fixed in 3.1.x branch?