Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exceptions encountered during tests with python 3.11 #199

Merged
merged 4 commits into from Oct 30, 2023

Conversation

netomi
Copy link
Contributor

@netomi netomi commented Oct 28, 2023

There are various exceptions during test execution when run on python 3.11:

image

These seems to be related to this issue:

python/cpython#109538

This PR adds the workaround as described in the ticket.

@netomi netomi marked this pull request as ready for review October 28, 2023 21:20
@netomi
Copy link
Contributor Author

netomi commented Oct 29, 2023

hmm, this fixes the other error it seems but creates a new error with dynamodb that I did not see locally, need to investigate.

@JWCook
Copy link
Member

JWCook commented Oct 30, 2023

Thanks for looking into this. Since this is new behavior as of 3.11.5, another option would be to update the github action to use 3.11.4, and hope this will be fixed in a future patch release.

@netomi
Copy link
Contributor Author

netomi commented Oct 30, 2023

that would be an option. Something that bothers me is the test execution in general. I see from the execution on GitHub, that 2 processes are spawned:

gw0 I / gw1 I
gw0 [507] / gw1 [507]

that seems to come from

  XDIST_ARGS: '--numprocesses=auto --dist=loadfile'

The tests succeed in general. However, if I run the same command on my local machine some of the tests fail, e.g. when run with --numprocesses=2 to simulate the GitHub action environment. The tests only succeed locally when run in a single process.

tn@proteus:~/workspace/netomi/aiohttp-client-cache$ poetry run pytest -rs --numprocesses=2 test/integration
=============================================================================================== test session starts ===============================================================================================
platform linux -- Python 3.10.12, pytest-7.4.3, pluggy-1.2.0
rootdir: /home/tn/workspace/netomi/aiohttp-client-cache
plugins: xdist-2.5.0, clarity-1.0.1, cov-2.12.1, asyncio-0.14.0, aiohttp-0.3.0, forked-1.6.0
gw0 [513] / gw1 [513]
.....F.......................................FF....................F.........................F.........FFFFFFF.FF......FFFFFFFFFFFFFF.FFF.................................................................. [ 39%]
......................................................................................................................F.................................................................................... [ 79%]
...F.........................................................................F.....................F.....F.                                                                                                 [100%]
==================================================================================================== FAILURES =====================================================================================================

Its most likely because the tests are run in parallel but access the same test-resources and thus the assumptions being made in the test are not valid anymore. However, I dont understand why it succeeds on GitHub?

@JWCook
Copy link
Member

JWCook commented Oct 30, 2023

What errors are you seeing locally?

The --dist=loadfile option parallelizes the tests by test module, so the integration tests won't be running more than one test at a time for a given backend. The only issues I've seen in the past when using xdist is when parallelizing by test function (default/--dist=load).

@netomi
Copy link
Contributor Author

netomi commented Oct 30, 2023

oh that is the trick I was missing, ty.

@JWCook
Copy link
Member

JWCook commented Oct 30, 2023

The main difference between local and CI environments is the resources available. GitHub Actions runners only have 2 cores, so at most only 2 tests will run at a time, while your local machine is probably able to run 8+ at a time. So if there's a race condition, it's less likely to show up in GitHub Actions. It's possible that this event_loop fixture isn't thread- or multiprocess-safe.

@netomi
Copy link
Contributor Author

netomi commented Oct 30, 2023

ok pinned the 3.11 for now, test execution looks very clean now.

@JWCook JWCook merged commit efe57fb into requests-cache:main Oct 30, 2023
6 checks passed
@netomi netomi deleted the fix-test-errors-with-python3.11 branch October 30, 2023 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants