str0zzapreti / pytest-retry

A simple plugin for retrying flaky tests in CI environments
MIT License
27 stars 6 forks source link

Fix: Prevent `ResourceWarning` when using `pytest-xdist` #39

Closed francis-clairicia closed 3 weeks ago

francis-clairicia commented 4 months ago

Hello! You told me in issue #26 to let you know if I noticed any problems, so here I am.

In an edge case which is very difficult to reproduce, the test suite could end with a small:

sys:1: ResourceWarning: unclosed <socket.socket fd=11, family=2, type=1, proto=0, laddr=('127.0.0.1', 33470), raddr=('127.0.0.1', 43621)>

And, after investigations, these are the sockets opened by the reporters which are not closed at the end of the process.

str0zzapreti commented 4 months ago

👀

str0zzapreti commented 4 months ago

@francis-clairicia Awesome, thanks for catching this. Do you have steps to replicate the issue? I saw you added a test matrix for xdist, but I only have the one xdist test currently in the suite which is specifically for reporting output. It would be ideal to have a test that covers this.

francis-clairicia commented 4 months ago

What I do know is this:

I'll try to reduce the scope to write the test.

francis-clairicia commented 3 months ago

@str0zzapreti Hello ! I found a way to test the warning in the main process (with ReportServer), but not for the xdist workers.

But at least there is a unit test.

str0zzapreti commented 3 months ago

Hey @francis-clairicia thanks for updating the test. I'll take a look as soon as I can

pashkatrick commented 1 month ago

any upds?

francis-clairicia commented 1 month ago

flake8 issues fixed.

str0zzapreti commented 1 month ago

Sorry for the delay @francis-clairicia I still want to test a couple of things but it looks good so far. Been very busy for the last couple months, but I should have some time today.

francis-clairicia commented 1 month ago

It's not a critical issue, but when your library is supposed to be a socket encapsulation and you see this at the end of the test suite, it makes you tick because it's hard to tell at first if it's coming from your code or from pytest. ^^

To be honest, I use your plugin to avoid using rerunfailures. So well, I'm a bit lazy to report this problem on their repo when I haven't come across the problem directly. What interests me most is that my test suite (which is already far too imposing for what it is) is completed.

str0zzapreti commented 1 month ago

Right, totally understand!

francis-clairicia commented 1 month ago

@str0zzapreti Changes done. Last review?

francis-clairicia commented 3 weeks ago

@str0zzapreti Changes done.