Skip to content

Commit 6bfe65d

Browse files
committed
Close attached file objects right in UVHandle._close()
1 parent 93ec1db commit 6bfe65d

File tree

2 files changed

+1
-9
lines changed

2 files changed

+1
-9
lines changed

uvloop/handles/handle.pxd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ cdef class UVHandle:
2727
cdef _dealloc_impl(self)
2828
cdef _free(self)
2929
cdef _close(self)
30-
cdef _after_close(self)
3130

3231

3332
cdef class UVSocketHandle(UVHandle):

uvloop/handles/handle.pyx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,6 @@ cdef class UVHandle:
217217
Py_INCREF(self)
218218
uv.uv_close(self._handle, __uv_close_handle_cb) # void; no errors
219219

220-
cdef _after_close(self):
221-
# Can only be called when '._close()' was called by hand
222-
# (i.e. won't be called on UVHandle.__dealloc__).
223-
pass
224-
225220
def __repr__(self):
226221
return '<{} closed={} {:#x}>'.format(
227222
self.__class__.__name__,
@@ -274,9 +269,9 @@ cdef class UVSocketHandle(UVHandle):
274269
cdef _close(self):
275270
if self.__cached_socket is not None:
276271
(<PseudoSocket>self.__cached_socket)._fd = -1
272+
277273
UVHandle._close(self)
278274

279-
cdef _after_close(self):
280275
try:
281276
# This code will only run for transports created from
282277
# Python sockets, i.e. with `loop.create_server(sock=sock)` etc.
@@ -299,7 +294,6 @@ cdef class UVSocketHandle(UVHandle):
299294
})
300295
finally:
301296
self._fileobj = None
302-
UVHandle._after_close(self)
303297

304298
cdef _open(self, int sockfd):
305299
raise NotImplementedError
@@ -363,7 +357,6 @@ cdef void __uv_close_handle_cb(uv.uv_handle_t* handle) with gil:
363357
h._loop._debug_handles_closed.update([
364358
h.__class__.__name__])
365359
h._free()
366-
h._after_close()
367360
finally:
368361
Py_DECREF(h) # Was INCREFed in UVHandle._close
369362

0 commit comments

Comments
 (0)