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

Optional setting single_json_encoder_class: Set json-compatible encoder class to generate_lock() #44

Merged
merged 3 commits into from
Oct 2, 2022

Conversation

tony
Copy link
Contributor

@tony tony commented Feb 23, 2022

Fixes cases such as #42 #36

json.dumps() accepts an optional cls of a jsonJSONEncoder

This matches the intention of the json library.

This is great for cases where users use a celery backend that supports passing uuid.UUID arguments and simply needs to cast. Many codebases already have an encoder for such purposes, some major packages have them such as django.core.serializers.json.DjangoJSONEncoder

@tony tony force-pushed the json-encoder-class branch 8 times, most recently from 0dccdbd to 764dee1 Compare February 23, 2022 21:51
@tony
Copy link
Contributor Author

tony commented Feb 24, 2022

@steinitzu Is it possible you could give this a peak?

Can you also fix master's tests?

@tony
Copy link
Contributor Author

tony commented May 24, 2022

@steinitzu Any update on this? Can you take a look?

@tony
Copy link
Contributor Author

tony commented Sep 1, 2022

@steinitzu Also giving another ping and letting you know I'd love for you to take a look at this

Thank you!

For django settings: CELERY_SINGLETON_JSON_ENCODER_CLASS

This allows settings a custom json.JSONEncoder class is one is passed.
By default behavior is preserved.

With this objects that are stringifiable can be passed to the celery
task.

Fixes steinitzu#36, 42

See also: https://docs.python.org/3/library/json.html#json.JSONEncoder
py.test tests/test_singleton.py::TestCustomJSONEncoder
@tony
Copy link
Contributor Author

tony commented Oct 2, 2022

@steinitzu Rebased after 35a16b2

@steinitzu
Copy link
Owner

Merging this as is. I'll fix the tests in a separate PR, they have other unrelated issues.

@steinitzu steinitzu merged commit a30b258 into steinitzu:master Oct 2, 2022
@tony tony deleted the json-encoder-class branch October 2, 2022 16:02
@tony
Copy link
Contributor Author

tony commented Oct 2, 2022

@steinitzu Thank you!

@tony
Copy link
Contributor Author

tony commented Oct 2, 2022

I'll fix the tests in a separate PR, they have other unrelated issues.

P.S. If you're interested in a CI setup for django + github actions, I have two examples you can use (MIT licensed):

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

Successfully merging this pull request may close these issues.

2 participants