Open PietroPasotti opened 2 years ago
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.
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
A link to a deeper dive after some more research
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
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: https://github.com/charmed-kubernetes/pytest-operator/blob/ab50fc20320d3ea3d8a37495f92a004531a4023f/pytest_operator/plugin.py#L171-L176
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.0In pytest-operator, we mess with the event loop here:
yarp: #119
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: https://github.com/python/cpython/issues/112741, explaining we are missing a condition to catch this corner case.
I get a bunch of these warnings when running the tests.
Maybe some develop branch is already preparing for these changes/upgrading a dependency version, but, to make sure...