Comments (5)
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.
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.
Hello, @ashleysommer Can not SanicContext objects be shared between processes, yet?
from sanic-plugin-toolkit.
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.
Thanks @ashleysommer I am going to check the library you suggest
from sanic-plugin-toolkit.
Related Issues (20)
- Example on Readme has incorrect import name HOT 2
- Memory leak in create_temporary_request_context() method HOT 7
- 0.8.2 change, new error HOT 5
- handling of arguments in SanicPlugin prevents multiple inheritance HOT 1
- Change to blueprints middleware handling in Sanic 19.12 breaks SPF and all SPF-based apps HOT 1
- You have taken the `spf` import name already belonging to `pyspf` HOT 5
- Deprecation of variables set on Sanic instances HOT 5
- 1.0.0 is not on pypi HOT 1
- Attributeerror: registration error occurred while registering the plug-in HOT 1
- Incorrect package naming HOT 2
- __new__() missing 1 required positional argument: 'version_prefix' HOT 1
- Sanic incompatibility problem HOT 1
- Incompatible with Sanic-21.12.0 HOT 5
- Websocket routes HOT 2
- Pipenv dependancy resolution error HOT 1
- Add context example? HOT 8
- setup.py doesn't install plugins, only spf HOT 1
- How to use with websocket blueprint? HOT 3
- Use proper semantic version HOT 2
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-plugin-toolkit.