Closed
Description
- uvloop version: 0.9.1
- Python version: 3.6.3
- Platform: OS X High Sierra
- Can you reproduce the bug with
PYTHONASYNCIODEBUG
in env?: Yes
I'm seeing a difference of behavior between the default asyncio event loop and uvloop when using a subprocess. When my code closes a subprocess transport under uvloop, the protocol's connection_lost handler is not called. The child process continues to show up in 'ps' output as a zombie.
The same behavior happens under ubuntu linux 16.04, with python 3.5.2.
The source code for 'test_subprocess.py' is below.
uvloop output:
$ python3 test_subprocess.py
connection_made
pipe_connection_lost 0
pipe_connection_lost 1
pipe_connection_lost 2
asyncio output:
$ NO_UVLOOP=1 python3 test_subprocess.py
connection_made
pipe_connection_lost 0
pipe_connection_lost 1
pipe_connection_lost 2
process_exited
connection_lost
test_subprocess.py:
import asyncio
import os
import uvloop
if 'NO_UVLOOP' not in os.environ:
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
class Protocol(asyncio.SubprocessProtocol):
def __init__(self):
self.closed = asyncio.get_event_loop().create_future()
def connection_made(self, transport):
print('connection_made')
def connection_lost(self, exc):
print('connection_lost')
self.closed.set_result(1)
def pipe_connection_lost(self, fd, exc):
print('pipe_connection_lost', fd)
def process_exited(self):
print('process_exited')
async def test_subprocess(loop):
transport, protocol = await loop.subprocess_exec(Protocol, '/bin/cat')
transport.close()
await protocol.closed
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(test_subprocess(loop))