File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,11 @@ def exception(self):
120
120
return self ._exception
121
121
122
122
def set_exception (self , exc ):
123
+ if isinstance (exc , ConnectionError ):
124
+ exc , old_exc = self ._eof_exc_class (), exc
125
+ exc .__cause__ = old_exc
126
+ exc .__context__ = old_exc
127
+
123
128
self ._exception = exc
124
129
125
130
if self ._output is not None :
Original file line number Diff line number Diff line change @@ -239,7 +239,7 @@ def start(self):
239
239
isinstance (handler , asyncio .Future )):
240
240
yield from handler
241
241
242
- except (ConnectionError , asyncio .CancelledError ,
242
+ except (asyncio .CancelledError ,
243
243
errors .ClientDisconnectedError ):
244
244
self .log_debug ('Ignored premature client disconnection.' )
245
245
break
Original file line number Diff line number Diff line change @@ -48,6 +48,17 @@ def test_exception(self):
48
48
stream .set_exception (exc )
49
49
self .assertIs (stream .exception (), exc )
50
50
51
+ def test_exception_connection_error (self ):
52
+ stream = parsers .StreamParser ()
53
+ self .assertIsNone (stream .exception ())
54
+
55
+ exc = ConnectionError ()
56
+ stream .set_exception (exc )
57
+ self .assertIsNot (stream .exception (), exc )
58
+ self .assertIsInstance (stream .exception (), RuntimeError )
59
+ self .assertIs (stream .exception ().__cause__ , exc )
60
+ self .assertIs (stream .exception ().__context__ , exc )
61
+
51
62
def test_exception_waiter (self ):
52
63
stream = parsers .StreamParser ()
53
64
You can’t perform that action at this time.
0 commit comments