Git Product home page Git Product logo

Comments (8)

PietroPasotti avatar PietroPasotti commented on July 30, 2024 2

If you pin pytest-asyncio==0.21.1 it'll work again.

There was a change in pytest-asyncio 0.23.0 that deprecated something this repo uses: https://github.com/pytest-dev/pytest-asyncio/releases/tag/v0.23.0

In pytest-operator, we mess with the event loop here:

@pytest.fixture(scope="module")
def event_loop():
"""Create an instance of the default event loop for each test module."""
loop = asyncio.get_event_loop_policy().new_event_loop()
yield loop
loop.close()

yarp: #119

from pytest-operator.

jnsgruk avatar jnsgruk commented on July 30, 2024 1

If you pin pytest-asyncio==0.21.1 it'll work again.

There was a change in pytest-asyncio 0.23.0 that deprecated something this repo uses: https://github.com/pytest-dev/pytest-asyncio/releases/tag/v0.23.0

In pytest-operator, we mess with the event loop here:

@pytest.fixture(scope="module")
def event_loop():
"""Create an instance of the default event loop for each test module."""
loop = asyncio.get_event_loop_policy().new_event_loop()
yield loop
loop.close()

from pytest-operator.

ca-scribner avatar ca-scribner commented on July 30, 2024

I don't think anyone is fixing this, but I believe it gets fixed by changing this line to @pytest_asyncio.fixture as discussed here. Otherwise, passing pytest the --asyncio-mode=auto command line arg will also sort this out.

from pytest-operator.

ca-scribner avatar ca-scribner commented on July 30, 2024

Actually sorry there's two warnings that pop up, and the fix I propose is more directly related to the other.

I don't think there's anything that can "fix" this deprecation warning at the pytest-operator level. I believe this must be addressed by the user calling pytest --asyncio-mode=auto or =strict. =strict might not work as expected though unless we also implement the @pytest_asyncio.fixture change mentioned above.

from pytest-operator.

ca-scribner avatar ca-scribner commented on July 30, 2024

FYI, for anyone coming to this after seeing an odd change in your code's behaviour, it might be because pytest-asyncio v0.19.0 changed the default valut of async-mode from auto to strict

from pytest-operator.

ca-scribner avatar ca-scribner commented on July 30, 2024

A link to a deeper dive after some more research

from pytest-operator.

PietroPasotti avatar PietroPasotti commented on July 30, 2024

Experiencing some related issues right now. Apparently pytest-operator is getting stuck for hours https://github.com/canonical/traefik-k8s-operator/actions/runs/7083208411/job/19275228212?pr=279
waiting on something

from pytest-operator.

phvalguima avatar phvalguima commented on July 30, 2024

Hi team, @jnsgruk++ @PietroPasotti++ for the proposal.

One thing I noticed is that pytest-operator + v0.23.2 pytest-asyncio results in we calling Python's asyncio mechanism with a brand new event loop, with no tasks in it nor any ready tasks yet. In my opinion, that should return rightaway. However, Python's _run_once with a fresh new event loop results in epoll_wait being called with timeout=-1:

Specifying a timeout of -1 causes epoll_wait() to block indefinitely

That is why we were hanging forever.

I filed a bug with Python: python/cpython#112741, explaining we are missing a condition to catch this corner case.

from pytest-operator.

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.