Comments (4)
I now see that this i has to do with ujson, and that in rare instances, what is inside the session contains objects that can’t be reliably dumped. The doc implies that I can put anything in the session but it seems that this is not the case at all.
I am using ujson==1.35
from sanic-session.
PyPI say that current stable version for the ujson is 3.2.0. Can you upgrade to the latest version? Probably the problem is already fixed. Module doesn't use any specific ujson features. It was chosen as faster alternative for standard json library from Python. It was an important speedup when module was written for the first time. As far as I know standard json is better now, so probably we can just drop support for json and use it only if it already installed.
If it is more convenient way for you pull request will be appreciated.
Something like:
try:
import ujson as json
except ModuleNotFoundError:
import json
from sanic-session.
I can’t use ujson==3.2.0
right now because they have removed the ability to convert objects starting in v2+. This is technically doable if you would consider adding a custom serializer for the dump — but right now it will break my application if I simply upgrade ujson
directly. (e.g. if dict contains datetime it will break immediately, whereas in 1.35 it will go through)
For example, there is no real reason why it must convert to json — if I am able to use pickle, for example. I have a full discussion on this matter on the sanic community here: https://community.sanicframework.org/t/mysterious-overflowerror-with-sanic-session/698/13?u=smlbiobot
And a quick solution would be for this library to support custom serializers (even if you only want to convert to json). Then I could get around this issue by doing custom json encoding to handle all of my use cases.
from sanic-session.
ujson is recommended dependency of Sanic framework itself. I think the more practical way for your case will be forking of sanic_session
. Or take only parts you needed and implement for yourself. This library is very simple but doesn't fit to your setup. Probably you need only 10-20 lines of code to implement your own sessions.
I will close the issue. There is nothing to do with sanic_sessions. Ofc, if you want to implement pluggable encoder/decoder you can do it, but I don't think it is very necessary in this specific project.
from sanic-session.
Related Issues (20)
- session does not save values (Sanic 20.3.0) HOT 2
- Update the release on PyPI HOT 2
- Document mongodb support? HOT 1
- AttributeError: 'NoneType' object has no attribute 'name' HOT 1
- UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 2490: character maps to <undefined>
- Session doesn't save HOT 8
- sys:1: RuntimeWarning: coroutine 'Loop.create_server' was never awaited
- Redis asyncio_redis example returns 403(timeout)
- How to use mongodb interface? HOT 1
- instance extensions question HOT 2
- Redis always “TimeoutError: [Errno 110] Connection timed out” HOT 1
- seems response header always has set-cookie, even use same session HOT 6
- aioredis example error in sanic 22.9.0 HOT 1
- Transfer of project HOT 2
- Why does this piece of code work? HOT 2
- Middleware addition is broken on sanic 22.12.0+ HOT 1
- Make the usage of json implementation configurable
- aioredis is now in redis >= 4.2
- this is base plugins, need to be more stable, more communal.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sanic-session.