Skip to content

Commit 9008581

Browse files
committed
Raise errors when asked to do so in {UVTransport|UVStreamServer}._fatal_error
1 parent f894ac7 commit 9008581

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

uvloop/handles/basetransport.pyx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,15 @@ cdef class UVBaseTransport(UVSocketHandle):
3939
cdef _fatal_error(self, exc, throw, reason=None):
4040
# Overload UVHandle._fatal_error
4141

42+
self._force_close(exc)
43+
4244
if not isinstance(exc, (BrokenPipeError,
4345
ConnectionResetError,
4446
ConnectionAbortedError)):
4547

48+
if throw or self._loop is None:
49+
raise exc
50+
4651
msg = 'Fatal error on transport {}'.format(
4752
self.__class__.__name__)
4853
if reason is not None:
@@ -55,8 +60,6 @@ cdef class UVBaseTransport(UVSocketHandle):
5560
'protocol': self._protocol,
5661
})
5762

58-
self._force_close(exc)
59-
6063
cdef inline _set_write_buffer_limits(self, int high=-1, int low=-1):
6164
if high == -1:
6265
if low == -1:

uvloop/handles/streamserver.pyx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,15 @@ cdef class UVStreamServer(UVSocketHandle):
6565
cdef _fatal_error(self, exc, throw, reason=None):
6666
# Overload UVHandle._fatal_error
6767

68+
self._close()
69+
6870
if not isinstance(exc, (BrokenPipeError,
6971
ConnectionResetError,
7072
ConnectionAbortedError)):
7173

74+
if throw or self._loop is None:
75+
raise exc
76+
7277
msg = 'Fatal error on server {}'.format(
7378
self.__class__.__name__)
7479
if reason is not None:
@@ -79,8 +84,6 @@ cdef class UVStreamServer(UVSocketHandle):
7984
'exception': exc,
8085
})
8186

82-
self._close()
83-
8487
cdef inline _mark_as_open(self):
8588
self.opened = 1
8689

0 commit comments

Comments
 (0)