Skip to content

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

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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