Kombu: Unable to use msgpack as result serializer (datetime object)

Created on 1 Mar 2019  路  8Comments  路  Source: celery/kombu

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).
  • [x] I have included all related issues and possible duplicate issues in this issue.
  • [x] I have included the contents of pip freeze in the issue.
  • [x] I have verified that the issue exists against the master branch of Celery.
  • [ ] I have tried reproducing the issue on more than one message broker and/or result backend.
  • [ ] I have tried reproducing the issue on more than one workers pool.
  • [x] I have tried reproducing the issue with retries, ETA/Countdown & rate limits disabled.

Related Issues and Possible Duplicates

Related Issues

Environment & Settings


Celery version: 4.3.0rc1 (rhubarb)



celery report Output:

software -> celery:4.3.0rc1 (rhubarb) kombu:4.3.0 py:3.5.6
            billiard:3.6.0.0 py-amqp:2.4.1
platform -> system:Linux arch:64bit, ELF
            kernel version:4.20.12-arch1-1-ARCH imp:CPython
loader   -> celery.loaders.app.AppLoader
settings -> transport:amqp results:redis://localhost:6379/0

accept_content: ['json', 'msgpack']
result_backend: 'redis://localhost:6379/0'
broker_url: 'amqp://user:********@localhost:5672/test'
result_serializer: 'msgpack'

Steps to Reproduce

Python Packages



pip freeze Output:

amqp==2.4.1
billiard==3.6.0.0
celery==4.3.0rc1
kombu==4.3.0
msgpack==0.6.1
pytz==2018.9
redis==3.2.0
vine==1.2.0

Minimally Reproducible Test Case

celeryconfig.py

broker_url = 'amqp://user:password@localhost/test'
result_backend = 'redis://localhost:6379/0'

result_serializer = 'msgpack'
accept_content = ['json', 'msgpack']
tasks.py
from celery import Celery


app = Celery('tasks')
app.config_from_object('celeryconfig')


@app.task
def add(x, y): 
    return x + y 
For convenience, here is a docker-compose.yml file
version: '3'

networks:
  celery_msgpack:

services:
  redis:
    image: redis:latest
    ports:
      - "6379:6379"
    networks:
      - celery_msgpack
  rabbitmq:
    image: rabbitmq:latest
    environment:
      - RABBITMQ_DEFAULT_USER=user
      - RABBITMQ_DEFAULT_PASS=password
      - RABBITMQ_DEFAULT_VHOST=test
    ports:
      - "5672:5672"
      - "15672:15672"
    networks:
      - celery_msgpack
Then, you just need to run the task to reproduce the error.

Expected Behavior


Serializing results with msgpack should still be possible. However, as far as I know, datetime objects are not supported yet. Maybe this date should be represented as a string (isoformat ?).

Actual Behavior