Skip to content

Commit

Permalink
test: Ignore subprocess tests when running on CPython 3.7.
Browse files Browse the repository at this point in the history
When run with Python 3.7 asyncio.subprocess.create_subprocess_exec seems to be
affected by an issue that prevents correct cleanup. Tests using pytest-trio
will report that signal handling is already performed by another library and
fail. [1] This is possibly a bug in CPython 3.7, so we ignore this test for
that Python version.

CPython 3.7 uses asyncio.streams.StreamReader and asyncio.streams.StreamWriter
to implement asyncio.streams.StreamReaderProtocol and
asyncio.subprocess.SubprocessStreamProtocol. StreamReaderProtocol contained
cyclic references between the reader and the protocol, which prevented
garbage collection. While StreamReaderProtocol received a patch [2],
SubprocessStreamProtocol, which is used by create_subprocess_exec, possibly
has the same problem, but was not patched as part of CPython 3.7.

That's why we ignore this test for CPython 3.7.

[1] python-trio/pytest-trio#126
[2] python/cpython#9201

Signed-off-by: Michael Seifert <[email protected]>
  • Loading branch information
seifertm committed Mar 11, 2022
1 parent ee1ed00 commit bae4c2d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ def event_loop():
loop.close()


@pytest.mark.skipif(
sys.version_info < (3, 8),
reason="""
When run with Python 3.7 asyncio.subprocess.create_subprocess_exec seems to be
affected by an issue that prevents correct cleanup. Tests using pytest-trio
will report that signal handling is already performed by another library and
fail. [1] This is possibly a bug in CPython 3.7, so we ignore this test for
that Python version.
[1] https://github.com/python-trio/pytest-trio/issues/126
""",
)
@pytest.mark.asyncio
async def test_subprocess(event_loop):
"""Starting a subprocess should be possible."""
Expand Down

0 comments on commit bae4c2d

Please sign in to comment.