@@ -24,17 +24,14 @@ async def read(self, n):
24
24
async def _fds_to_asyncio (rfd , wfd , loop ):
25
25
reader = asyncio .StreamReader (loop = loop )
26
26
reader_protocol = asyncio .StreamReaderProtocol (reader , loop = loop )
27
+ rf = open (rfd , "rb" , 0 )
28
+ rt , _ = await loop .connect_read_pipe (lambda : reader_protocol , rf )
27
29
28
30
wf = open (wfd , "wb" , 0 )
29
- transport , _ = await loop .connect_write_pipe (
30
- FlowControlMixin , wf )
31
- writer = asyncio .StreamWriter (transport , reader_protocol ,
32
- None , loop )
33
-
34
- rf = open (rfd , "rb" , 0 )
35
- await loop .connect_read_pipe (lambda : reader_protocol , rf )
31
+ wt , _ = await loop .connect_write_pipe (FlowControlMixin , wf )
32
+ writer = asyncio .StreamWriter (wt , reader_protocol , None , loop )
36
33
37
- return reader , writer
34
+ return rt , reader , writer
38
35
39
36
40
37
class AsyncioParentComm (_BaseIO ):
@@ -47,6 +44,7 @@ def get_address(self):
47
44
48
45
async def _autoclose (self ):
49
46
await self .process .wait ()
47
+ self .reader_transport .close ()
50
48
self .writer .close ()
51
49
52
50
async def create_subprocess (self , * args , ** kwargs ):
@@ -56,8 +54,8 @@ async def create_subprocess(self, *args, **kwargs):
56
54
os .close (self .c_rfd )
57
55
os .close (self .c_wfd )
58
56
59
- self .reader , self .writer = await _fds_to_asyncio (
60
- self .p_rfd , self .p_wfd , loop )
57
+ self .reader_transport , self . reader , self .writer = \
58
+ await _fds_to_asyncio ( self .p_rfd , self .p_wfd , loop )
61
59
asyncio .ensure_future (self ._autoclose ())
62
60
63
61
@@ -67,10 +65,12 @@ def __init__(self, address):
67
65
68
66
async def connect (self ):
69
67
rfd , wfd = self .address .split ("," , maxsplit = 1 )
70
- self .reader , self .writer = await _fds_to_asyncio (
71
- int (rfd ), int (wfd ), asyncio .get_event_loop ())
68
+ self .reader_transport , self .reader , self .writer = \
69
+ await _fds_to_asyncio (int (rfd ), int (wfd ),
70
+ asyncio .get_event_loop ())
72
71
73
72
def close (self ):
73
+ self .reader_transport .close ()
74
74
self .writer .close ()
75
75
76
76
0 commit comments