Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Celery error when using rabbitmq as broker #16

Closed
ne018 opened this issue Oct 30, 2020 · 1 comment
Closed

Celery error when using rabbitmq as broker #16

ne018 opened this issue Oct 30, 2020 · 1 comment

Comments

@ne018
Copy link

ne018 commented Oct 30, 2020

[2020-10-30 18:02:56,696: INFO/ForkPoolWorker-2] Task massmailer.tasks.send_email[massmailer-aeaa2e15-a1b6-4e78-8317-253a7f21654a] retry: Retry in 60s: TypeError("Object of type 'UUID' is not JSON serializable",)
[2020-10-30 18:02:56,698: INFO/MainProcess] Received task: massmailer.tasks.send_email[massmailer-aeaa2e15-a1b6-4e78-8317-253a7f21654a]  ETA:[2020-10-30 18:03:56.694045+00:00] 
[2020-10-30 18:03:56,843: WARNING/ForkPoolWorker-2] Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: Hi myemail@gmail.com
From: webmaster@localhost
To: myemail@gmail.com
Date: Fri, 30 Oct 2020 18:03:56 -0000
Message-ID: <160408103684.2439.2899414189599422213@ubuntu-bionic>
X-MID: aeaa2e15-a1b6-4e78-8317-253a7f21654a

Hello this is a test
[2020-10-30 18:03:56,843: WARNING/ForkPoolWorker-2] -------------------------------------------------------------------------------
[2020-10-30 18:03:56,861: ERROR/ForkPoolWorker-2] Task massmailer.tasks.send_email[massmailer-aeaa2e15-a1b6-4e78-8317-253a7f21654a] raised unexpected: TypeError("Object of type 'UUID' is not JSON serializable",)
Traceback (most recent call last):
  File "/home/vagrant/.local/lib/python3.6/site-packages/celery/app/trace.py", line 409, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/home/vagrant/.local/lib/python3.6/site-packages/celery/app/trace.py", line 701, in __protected_call__
    return self.run(*args, **kwargs)
  File "/home/vagrant/.local/lib/python3.6/site-packages/massmailer/tasks.py", line 51, in send_email
    raise self.retry(exc=exc)
  File "/home/vagrant/.local/lib/python3.6/site-packages/celery/app/task.py", line 701, in retry
    raise_with_context(exc)
  File "/home/vagrant/.local/lib/python3.6/site-packages/massmailer/tasks.py", line 39, in send_email
    ret = python_mail.send(fail_silently=False)
  File "/home/vagrant/.local/lib/python3.6/site-packages/django/core/mail/message.py", line 284, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/home/vagrant/.local/lib/python3.6/site-packages/sendgrid_backend/mail.py", line 129, in send_messages
    resp = self.sg.client.mail.send.post(request_body=data)
  File "/home/vagrant/.local/lib/python3.6/site-packages/python_http_client/client.py", line 257, in http_request
    data = json.dumps(request_body).encode('utf-8')
  File "/usr/lib/python3.6/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/usr/lib/python3.6/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python3.6/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib/python3.6/json/encoder.py", line 180, in default
    o.__class__.__name__)
TypeError: Object of type 'UUID' is not JSON serializable

It's working when im using simple custom task with send_mail but when sending batch mail from massmailer, it persist.

@ne018
Copy link
Author

ne018 commented Oct 30, 2020

i solved it by converting id in model to string. str(self.id)

@ne018 ne018 closed this as completed Oct 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant