-
Notifications
You must be signed in to change notification settings - Fork 1
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
beat fails to start with UnicodeDecodeError in celery_schedulers/redis_scheduler #227
Comments
Problem is pickles aren't compatible from Python 2.7 to 3.6:
|
Or more concisely:
|
It's an open bug in Python. |
The workaround for datetime is to use
Unfortunately, if you do that with the celerybeat schedule pickle, another issue arises:
That's because |
The resolution of the upstream ticket is "don't use pickle". So maybe that's the solution. It does appear that using jsonpickle works around the issue:
Maybe next I'll test to see if the whole document in redis could be serialized and deserialized by jsonpickle, but not tonight. |
I tried serializing the objects on Python 2 and deserializing on Python 3 using jsonpickle, and while the operation succeeded, it did not provide an accurate representation on Python 3:
I'm now recommending that to upgrade the beat proc from Python 2 to Python 3 that the |
If we go with the option of "flushing" the existing messages (+1 from me), we should also consider dropping pickle altogether and use a more portable serialization format (json, msgpack, etc.) |
I found the cause for the jsonpickle not working in jsonpickle/jsonpickle#216. If that bug is repaired, we probably could rely on jsonpickle for a more portable, json-based serialization that works across Pythons. We could also write a custom handler for ScheduleEntry objects that works around the bug in jsonpickle 0.9.6. When you suggest using JSON, I suspect you mean explicitly hand-encoding each type of object in the schedule entries. I'd worry that any such approach would be brittle, as the serialization would have to keep tabs on the exact structure of the objects being stored (which could change with upstream changes). The jsonpickle project seeks to solve this issue generically, by providing a robust and human-readable serialization for any serializable Python types. It would be less likely to break if there were changes in the object structure.
I'm actually unsure if this is an option. I was presuming that these schedules get created automatically, but I'm not sure they do. We'd have to verify that they do before flushing them. What I could do is save the redis pickle, restart the beat proc, and see if the schedules come back on their own... and if not, restore the pickle. |
I see the definitions in the settings CELERYBEAT_SCHEDULE, so I'm pretty sure they'll recreate themselves. I stopped the Py2 version, deleted the celerybeat_schedule, started the py3 version, then confirmed it had recreated the schedule:
|
The text was updated successfully, but these errors were encountered: