-
Notifications
You must be signed in to change notification settings - Fork 550
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
Cannot use sys.stdout
in create_subprocess_exec
.
#136
Comments
I'm facing the same/similar error in my Travis CI environment.
|
Fixed in master. Please test! |
In 0.14.0 still present platform darwin -- Python 3.6.10, pytest-5.4.2, py-1.8.1, pluggy-0.13.1 Code failed with same issue: def _parse_list(output, files_patt):
patt = r'(\d+)\s+.{16}\s+(%s)' % files_patt
return re.findall(patt, output)
async def list_files(cls, rar_file: str, files_patt):
process = await asyncio.create_subprocess_exec(
'unrar', 'l', rar_file,
stdout=asyncio.subprocess.PIPE,
)
output, _ = await process.communicate()
if process.returncode != os.EX_OK:
raise RuntimeError(
f'unrar failed: return_code={process.returncode!r}')
return [(int(size), name) for size, name in _parse_list(output.decode(), files_patt)]
csv_in_rar_count = await list_files(rar_path, '(?i).*CSV') |
|
Whatever the underlying problem is here, it definitely has not been closed out. I have found that it can be worked around in tests where it pops up by using the default event loop policy via a pytest mark at the top of my test files that hit the issue. Hopefully, this helps until we can nail down the underlying issue: # NOTE: These tests are brittle when run under uvloop. We run these under the default
# asyncio event loop policy to avoid exceptions relating to pytest output capture.
# The exception is: `io.UnsupportedOperation: redirected stdin is pseudofile, has no fileno()`
pytestmark = [pytest.mark.asyncio, pytest.mark.event_loop_policy("default")] |
This error message is from pytest. If you try to read from stdin, it also says:
I'm checking why asyncio doesn't fail this test. |
This aligns uvloop with the same behavior in asyncio - when stdin, stdout or stderr is None, the subprocess will use FD 0, 1 or 2 now instead of sys.stdin, sys.stdout or sys.stderr. Fixes MagicStack#136
This aligns uvloop with the same behavior in asyncio - when stdin, stdout or stderr is None, the subprocess will use FD 0, 1 or 2 now instead of sys.stdin, sys.stdout or sys.stderr. Fixes MagicStack#136
This aligns uvloop with the same behavior in asyncio - when stdin, stdout or stderr is None, the subprocess will use FD 0, 1 or 2 now instead of sys.stdin, sys.stdout or sys.stderr. Fixes #136
PYTHONASYNCIODEBUG
in env?: Same behavior irregardless ofPYTHONASYNCIODEBUG
.Code for reproduction:
Output:
The text was updated successfully, but these errors were encountered: