Skip to content

Subprocess leaking #185

Closed
Closed
@ttill

Description

@ttill
  • uvloop version: 0.11.0
  • Python version: 3.6.6
  • Platform: Linux (Archlinux)
  • Can you reproduce the bug with PYTHONASYNCIODEBUG in env?: yes

A lot of subsequent failing calls to asyncio.create_subprocess_exec cause a Too many open files OS error. Using the standard event loop, I do not get an error thrown.

Here is a minimal example:

import asyncio
import uvloop

async def m():
    for i in range(0, 10000):
        try:
            await asyncio.create_subprocess_exec('nonexistant')
        except FileNotFoundError:
            print(i)
        await asyncio.sleep(.001)

asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
asyncio.get_event_loop().run_until_complete(m())

Output:

[…]
333
334
335
Traceback (most recent call last):
  File "uvseg.py", line 13, in <module>
    asyncio.get_event_loop().run_until_complete(m())
  File "uvloop/loop.pyx", line 1448, in uvloop.loop.Loop.run_until_complete
  File "uvseg.py", line 7, in m
    await asyncio.create_subprocess_exec('nonexistant')
  File "/usr/lib64/python3.6/asyncio/coroutines.py", line 110, in __next__
    return self.gen.send(None)
  File "/usr/lib64/python3.6/asyncio/subprocess.py", line 225, in create_subprocess_exec
    stderr=stderr, **kwds)
  File "uvloop/loop.pyx", line 2603, in subprocess_exec
  File "uvloop/loop.pyx", line 2563, in __subprocess_run
  File "uvloop/handles/process.pyx", line 580, in uvloop.loop.UVProcessTransport.new
  File "uvloop/handles/process.pyx", line 87, in uvloop.loop.UVProcess._init
OSError: [Errno 24] Too many open files

The same code runs until the end when removing asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()).

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