Comments (5)
Hey George, I'm not sure how much work this is to implement. I'm not against the idea of "bjoernlocals" in general as long as they don't require extensive changes, but to be honest I'm not interested enough in this feature to code it myself.
So if you really need thread locals you're probably better off using a different Web server (or implement the feature yourself, of course :-).
from bjoern.
Thanks for the reply, I'm afraid this is a deal breaker for me and I'd guess for many non trivial web apps. Most frameworks expose some sort of "global" objects such as the current request, db session, etc; without it you'd need to pass them explicitly in all function and method calls, starting from the top level wsgi app all the way down the stack. For multithreaded servers, thread locals is a natural fit for this. Async servers still face the same problem though, and they should either monkeypatch thread locals or offer an alternative mechanism for such request-specific "globals".
from bjoern.
As I said I'm not aversed to having some sort of thread locals in bjoern, it's just missing someone to implement it.
Maybe if more users demand this feature I'm going to try to implement it but you're the first one so far to request thread locals.
(Which either means nobody uses bjoern or it works well enough without thread locals [Django].)
from bjoern.
I discovered Contextual, a package that addresses the need for global state in a safe, context-dependent way. Probably worth a look for you or anyone else that comes across this problem.
Feel free to close this issue if it's not a priority.
from bjoern.
It doesn't seem to work. Here's a test script that sends two requests so that bjoern interrupts the handler after the yield
. The counter doesn't start at 0 for the second "coroutine". https://gist.github.com/2057811
from bjoern.
Related Issues (20)
- Bjoern 200-300 rps vs gunicorn 500/600 rps HOT 1
- site don't work
- pip install fails - missing http_parser.h HOT 2
- How to trigger server restart on source file changes? HOT 1
- Build fails on M1 Mac using Homebrew HOT 9
- calling from command line like gunicorn in Profcfile HOT 2
- Build bjoern error in mac m1 with command `pip3 install --global-option=build_ext --global-option="-I/opt/homebrew/include" bjoern` HOT 6
- Production use HOT 1
- Remove flask example HOT 5
- pip install not working on ubuntu 20.04 HOT 5
- Compilation terminated - fatal error: http_parser.h: No such file or directory HOT 1
- Extending to asgi HOT 7
- pip install error HOT 1
- Autostart after changes HOT 1
- broken pipe after running for a while HOT 3
- symbol not found in flat namespace '_ev_cleanup_start'
- pip installation fails (bjoern/request.h:4:10: fatal error: 'ev.h' file not found) HOT 2
- Apple Silicon build not supported. HOT 7
- ev.h not found; command /usr/bin/gcc exit failed with exit code 1 HOT 3
- Processed request response stuck when workers are not available HOT 20
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 bjoern.