ApiLogicServer-src
ApiLogicServer-src copied to clipboard
Postgres unknown object timedelta
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
Per screen shot below, this appears to be coming from safrs; unclear how to resolve.
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 (https://github.com/thomaxxl/safrs/commit/56f3839fd5427420102d4676b0b5326db6bca184) .
The json encoding (patch/post) will fail though.