Giter VIP home page Giter VIP logo

Comments (5)

klausmyrseth avatar klausmyrseth commented on May 19, 2024

I might have a culprint here, running Sanic with two processes, and now I have two entries randomly shifting when I list the context.

Thought the context was shared between the processes?

from sanic-plugin-toolkit.

ashleysommer avatar ashleysommer commented on May 19, 2024

Hi @klausmyrseth
You're absolutely right, this is caused by running Sanic with two process workers.

Currently the SanicContext objects are not shared between processes. I'll put a note in the Readme to make that clear.

This is something I'd like to fix in an upcoming release, but unfortunately that is a feature that would add a large latency overhead to shared context objects. It would ruin some of our performance.

For now the best thing you can do is put a middleware somewhere near the start of your request to check if your entry is present in the shared context, and if not, re-initialise it on that process.

from sanic-plugin-toolkit.

jonra1993 avatar jonra1993 commented on May 19, 2024

Hello, @ashleysommer Can not SanicContext objects be shared between processes, yet?

from sanic-plugin-toolkit.

ashleysommer avatar ashleysommer commented on May 19, 2024

Hi @jonra1993
No, sorry Sanic-Plugin-Context cannot share objects between processes yet.

However, this month I released Sanic-Synchro-CTX that is a new Sanic plugin that allows you to share context objects between worker processes (using either Redis as a server or using native Python Sync Objects).

That plugin is not a Sanic-Plugin-Toolkit plugin, and might not play well with Sanic-Plugin-Toolkit.
However it does mean that I can probably merge that functionality into Sanic-Plugin-Toolkit in the next version.

from sanic-plugin-toolkit.

jonra1993 avatar jonra1993 commented on May 19, 2024

Thanks @ashleysommer I am going to check the library you suggest

from sanic-plugin-toolkit.

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.