-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
IOError: close() called during concurrent operation on the same file object. #2370
Comments
I think some code under test is closing If you pass pytest by default captures |
Closing for now due to lack of feedback, but we can reopen this later if new information comes along. |
@nicoddemus I'm seeing this issue again. If I pass -s, it will create a lot of output and overwhelm my CI logs. This is hard to nail down since I have thousands of tests and its not deterministic. Can some defensive logic be added around the file close statement to avoid this? |
Hi @blockjon,
I would be OK if we could reproduce the problem and understand what's happening but just adding some defensive logic in there, without knowing why, is problematic in the long term as it might be hiding some bug. I suggest we investigate more. I can see from the traceback that the error happens here: Lines 530 to 533 in 9fcbf57
A quick search suggests that threads are somehow involved:
But pytest itself does not use threads internally at all, so I'm puzzled as to how this is happening. Some questions:
|
Here's a test file that reproduces it for me 100% of the time:
While this example is silly, the error can come up in practice if there's a background thread logging something at an inopportune moment during shutdown. |
…ng streams in Python 2.7. Fix pytest-dev#2370
Thanks a lot @benjaminp! Using this sample I can also reproduce this on latest pytest on Windows, Python 2.7 (but not on 3.6). Opened #3305 with a fix. |
…ng streams in Python 2.7. Fix pytest-dev#2370
On Tue, Mar 13, 2018, at 13:43, Bruno Oliveira wrote:
Thanks a lot @benjaminp! Using this sample I can also reproduce this on
latest pytest on Windows, Python 2.7 (but not on 3.6).
Yeah, the Python 3 IO stack does not share this quirk.
|
It fails reliable for me now without the fix from 9517c3a, and had actually a wrong assertion in the end. Ref: pytest-dev#2370
It fails reliable for me now without the fix from 9517c3a. Ref: pytest-dev#2370
Occasionally, I get
IOError: close() called during concurrent operation on the same file object.
when my tests run. I'm not sure what I should do to resolve this.PIP LIST:
https://gist.github.com/blockjon/787895c8f5aab3b2587051b919e4e037
PYTEST:
pytest (3.0.5)
OS:
Debian Jessie running Docker Container
TRACE:
The text was updated successfully, but these errors were encountered: