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

Address PyPy flakiness in test_for_leaking_fds #2888

Merged
merged 1 commit into from
Nov 27, 2023

Conversation

A5rocks
Copy link
Contributor

@A5rocks A5rocks commented Nov 25, 2023

Refs #2885

I've run the PyPy test suite a lot and this test in particular has failed.

See https://github.com/A5rocks/trio/actions/runs/6953123771/job/18951033826#step:5:5284 for an example of this happening.

I'm guessing that this is because PyPy GC is weird and isn't guaranteed to clean up previous test objects which might contain something with a file descriptor. I added this here and I didn't get this test to fail again in a bunch of runs, so I think this fixes that.

Now I'm kinda thinking of if it's possible to upstream this in pytest, because this kind of thing is insidious. https://foss.heptapod.net/pypy/pypy/-/commit/5a6a733370542b26e7c4ee756c4fb566523e53d8 introduces a new PyPy GC API that can address this more generally, I believe.

@A5rocks A5rocks mentioned this pull request Nov 25, 2023
17 tasks
Copy link

codecov bot commented Nov 25, 2023

Codecov Report

Merging #2888 (e835f77) into master (9c496fa) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2888   +/-   ##
=======================================
  Coverage   99.54%   99.54%           
=======================================
  Files         115      115           
  Lines       17660    17662    +2     
  Branches     3165     3165           
=======================================
+ Hits        17580    17582    +2     
  Misses         52       52           
  Partials       28       28           
Files Coverage Δ
src/trio/_tests/test_subprocess.py 100.00% <100.00%> (ø)

Copy link
Member

@jakkdl jakkdl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely seems like something that should get fixed somewhere upstream in one way or another, but definitely doesn't hurt to fix in CI for now.

To track the issue one could run the test once before doing gc.collect(), and then rerun it after a collect() on failure - although I'm not sure how to collect data from that.

@A5rocks
Copy link
Contributor Author

A5rocks commented Nov 27, 2023

I think the problem is that even without that gc.collect() that tracking method would succeed because the only reason the assertion is failing is because things are getting cleaned up too late. (But after it fails, they're already cleaned up)

@A5rocks A5rocks merged commit 071d636 into python-trio:master Nov 27, 2023
30 of 31 checks passed
@A5rocks A5rocks deleted the pypy-flakiness branch November 27, 2023 23:29
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.

2 participants