-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
OSError('[Errno 24] Too many open files') with pytest 3.3.0 #2970
Comments
Hi @vphilippon thanks for the detailed report. Could you try to see which files are being kept open? AFAIK |
Thanks for the quick reply, I'll check this tomorrow morning (EST) |
Another thing to try: one new addition was the new logging plugin, try running the test suite with |
Reporting back:
|
Update on the
with the same 2 temp files everytime. So nothing like something that would cause a "to many opened files" issue. |
The leaking process is not from the I managed to make a reproducible case:
conftest.py
test.py
|
Thanks @vphilippon for following up! I can reproduce the issue, and I see it is related to #2968 (comment): you are relying on the garbage collector to implicitly close the If you explicitly close it the process leak goes away: @pytest.fixture(scope="session")
def remote_repo(tmpdir_factory):
tmpdir = tmpdir_factory.mktemp('repos')
tmpdir.chdir()
os.mkdir('remote')
# Repo init (on master by default)
repo = git.Repo.init('remote')
repo.index.commit('master 1st commit')
repo.index.commit('master 2nd commit')
yield repo
repo.close()
@pytest.fixture()
def local_repo_per_test(tmpdir, remote_repo):
clone = remote_repo.clone(str(tmpdir.join('./local')))
os.chdir(clone.working_dir)
yield clone
clone.close() This is definitely a bug in pytest that we intend to fix, but either way explicitly closing your resources is considered good-practice. 👍 |
Well color me surprised, I didn't even knew the |
Great, thanks @vphilippon for patience and understanding! |
…alstead metric typo which was leaving files unopened
Thank you for this well documented issue, I stumbled across the same thing 👍 @nicoddemus |
After upgrading to
pytest
3.3.0 (previously on 3.2.5), my unitests usingpytest
andGitPython
are failing with:More precisely, all of my tests pass up to a certain number (I don't have the exact number right now), and then all the following tests start failing due to that error.
Unfortunately, I cannot share the code and tests (private projects).
Here's a partial
pip list
, after removing a set of private packages:What I can tell is that those tests perform a lot of "git clone" operation into temp directories made using the
tmpdir
andtmpdir_factory
fixtures.The only peculiar thing I can think of about my use case is that I have some fixtures from the "per test" level using "session" level fixtures.
Here's an almost identical copy of the
conftest.py
:And then I have tests using
local_repo_per_session
orlocal_repo_per_test
depending on if the test is only doing reads, or if it will change the repo given by the fixture.It feels as if the file handler for per-test level fixtures aren't closed properly anymore, but that's only my guess.
You can ask for more details about the tests, I'll try to give as much information as I can / am allowed to.
Pytest version: 3.3.0
Python: 2.7 (32 bits version)
OS: Windows 7/10
pip list
of the virtual environment you are usingThe text was updated successfully, but these errors were encountered: