Skip to content

subprocess.communicate never returns when the subprocess outputs more than 0xFFFF + 1 bytes #363

Closed
@riouh

Description

@riouh
  • uvloop version: uvloop==0.14.0
  • Python version: Python 3.8.6
  • Platform: MacOS
  • Can you reproduce the bug with PYTHONASYNCIODEBUG in env?: yes
  • Does uvloop behave differently from vanilla asyncio? How?: yes. vanilla asyncio just works

The following code never returns with uvloop :

import asyncio
from asyncio.subprocess import PIPE
import uvloop
import logging

logging.basicConfig(level=logging.DEBUG)


async def main():
    proc = await asyncio.create_subprocess_exec("/bin/cat", stdin=PIPE, stderr=PIPE, stdout=PIPE)
    stdin = b'x' * 65_537
    stdout, stderr = await proc.communicate(stdin)
    print(stdout)


uvloop.install()
asyncio.run(main())

changing 65_537 to 65_536 makes the script work as expected and returns immediately.

The debug output is :

 % PYTHONASYNCIODEBUG=1 python xxx.py
DEBUG:asyncio:<Process 13746> communicate: feed stdin (65537 bytes)
DEBUG:asyncio:<Process 13746> communicate: close stdin
DEBUG:asyncio:<Process 13746> communicate: read stdout
DEBUG:asyncio:<Process 13746> communicate: read stderr

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions