File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -515,6 +515,7 @@ def test_tcp_handle_exception_in_connection_made(self):
515
515
self .loop .set_exception_handler (lambda * args : None )
516
516
517
517
fut = asyncio .Future (loop = self .loop )
518
+ connection_lost_called = asyncio .Future (loop = self .loop )
518
519
519
520
async def server (reader , writer ):
520
521
try :
@@ -526,6 +527,9 @@ class Proto(asyncio.Protocol):
526
527
def connection_made (self , tr ):
527
528
1 / 0
528
529
530
+ def connection_lost (self , exc ):
531
+ connection_lost_called .set_result (exc )
532
+
529
533
srv = self .loop .run_until_complete (asyncio .start_server (
530
534
server ,
531
535
'127.0.0.1' , 0 ,
@@ -545,6 +549,9 @@ async def runner():
545
549
self .loop .run_until_complete (srv .wait_closed ())
546
550
self .loop .run_until_complete (fut )
547
551
552
+ self .assertIsNone (
553
+ self .loop .run_until_complete (connection_lost_called ))
554
+
548
555
549
556
class Test_UV_TCP (_TestTCP , tb .UVTestCase ):
550
557
Original file line number Diff line number Diff line change @@ -128,14 +128,17 @@ cdef class UVBaseTransport(UVSocketHandle):
128
128
129
129
_loop_ready_len = self ._loop._ready_len
130
130
131
+ # Set _protocol_connected to 1 before calling "connection_made":
132
+ # if transport is aborted or closed, "connection_lost" will
133
+ # still be scheduled.
134
+ self ._protocol_connected = 1
135
+
131
136
try :
132
137
self ._protocol.connection_made(self )
133
138
except :
134
139
self ._wakeup_waiter()
135
140
raise
136
141
137
- self ._protocol_connected = 1
138
-
139
142
if self ._closing:
140
143
# This might happen when "transport.abort()" is called
141
144
# from "Protocol.connection_made".
You can’t perform that action at this time.
0 commit comments