Git Product home page Git Product logo

Comments (5)

jonashaag avatar jonashaag commented on September 27, 2024

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.

gsakkis avatar gsakkis commented on September 27, 2024

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.

jonashaag avatar jonashaag commented on September 27, 2024

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.

gsakkis avatar gsakkis commented on September 27, 2024

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.

jonashaag avatar jonashaag commented on September 27, 2024

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)

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.