Git Product home page Git Product logo

Comments (4)

smlbiobot avatar smlbiobot commented on June 18, 2024

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.

xen avatar xen commented on June 18, 2024

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.

smlbiobot avatar smlbiobot commented on June 18, 2024

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.

xen avatar xen commented on June 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.