GithubHelp home page GithubHelp logo

Comments (5)

Dreamsorcerer avatar Dreamsorcerer commented on June 13, 2024

Personally, I find ContextVar to be a bad idea, and it's not clear when a context is created/removed. The purpose of ContexVar appears to be more related to have a context for each request or similar, I think using them as an app-wide global will only lead to problems (problems I've recently encountered with another library that uses them like this).

from pytest-aiohttp.

Dreamsorcerer avatar Dreamsorcerer commented on June 13, 2024

Having said that, it does appear to be documented behaviour: https://docs.aiohttp.org/en/stable/web_advanced.html#contextvars-support
So, I'm wondering if the bug might even be in aiohttp.

from pytest-aiohttp.

webknjaz avatar webknjaz commented on June 13, 2024

I believe that @asvetlov mentioned that there's something that needs to be improved wrt case (long ago, in private chats). But I don't remember what exactly and I ended up not going down the rabbit hole myself back then. I seem to recall some connection to the cleanup contexts but maybe I'm misremembering.

from pytest-aiohttp.

asvetlov avatar asvetlov commented on June 13, 2024

Should be done as a part of pytest-asyncio plugin. Stay tuned.

from pytest-aiohttp.

asvetlov avatar asvetlov commented on June 13, 2024

@Dreamsorcerer contextvars were initially created to solve decimal localcontext problem when it is used in async code.

Generally speaking, they are as bad as thread-local variables, not better and not worse.
I'm trying to avoid contextvars usage in architecture design, but they are useful for tooling like logging, distributed tracing, etc.

from pytest-aiohttp.

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.