Skip to content

Postgres unknown object timedelta #32

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

Open
valhuber opened this issue Dec 8, 2023 · 2 comments
Open

Postgres unknown object timedelta #32

valhuber opened this issue Dec 8, 2023 · 2 comments
Assignees

Comments

@valhuber
Copy link
Contributor

valhuber commented Dec 8, 2023

Loading the docker postgres stress shows log with many of:

JSON Encoding Error: Unknown object type "<class 'datetime.timedelta'>" for 0:00:00
JSON Encoding Error: Unknown object type "<class 'datetime.timedelta'>" for 0:00:00
JSON Encoding Error: Unknown object type "<class 'datetime.timedelta'>" for 0:00:00
@valhuber valhuber self-assigned this Dec 8, 2023
@valhuber
Copy link
Contributor Author

Per screen shot below, this appears to be coming from safrs; unclear how to resolve.

JSON encoding error

postgres-stress.zip

@valhuber valhuber assigned thomaxxl and unassigned valhuber Dec 11, 2023
@thomaxxl
Copy link
Collaborator

Hi,

In case of json encoding errors like this you can write a custom JSON encoder for flask/safrs and use that (set app.json_encoder, cfr. https://github.com/thomaxxl/safrs/blob/714708ae9b6eb5a86517c867b32caeea8d05e681/safrs/json_encoder.py#L156 ).

Note that in DEBUG mode, the encoding will default to str(), if safrs isn't running in debug then you will get an error.

I added a timedelta encoding to safrs (thomaxxl/safrs@56f3839) .

The json encoding (patch/post) will fail though.

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

2 participants