diff --git a/uvloop/handles/handle.pxd b/uvloop/handles/handle.pxd index be123c36..01cbed09 100644 --- a/uvloop/handles/handle.pxd +++ b/uvloop/handles/handle.pxd @@ -24,7 +24,6 @@ cdef class UVHandle: cdef _warn_unclosed(self) - cdef _dealloc_impl(self) cdef _free(self) cdef _close(self) diff --git a/uvloop/handles/handle.pyx b/uvloop/handles/handle.pyx index 1e1d1d1a..3e3ee2cb 100644 --- a/uvloop/handles/handle.pyx +++ b/uvloop/handles/handle.pyx @@ -26,9 +26,6 @@ cdef class UVHandle: self.__class__.__name__)) def __dealloc__(self): - self._dealloc_impl() - - cdef _dealloc_impl(self): if UVLOOP_DEBUG: if self._loop is not None: self._loop._debug_handles_current.subtract([ @@ -40,9 +37,6 @@ cdef class UVHandle: .format(self.__class__.__name__)) if self._handle is NULL: - if UVLOOP_DEBUG: - if self._has_handle == 0: - self._loop._debug_uv_handles_freed += 1 return # -> When we're at this point, something is wrong <- diff --git a/uvloop/handles/process.pyx b/uvloop/handles/process.pyx index 2ac7b4c1..41ea811c 100644 --- a/uvloop/handles/process.pyx +++ b/uvloop/handles/process.pyx @@ -190,7 +190,7 @@ cdef class UVProcess(UVHandle): 'UVProcess._close_after_spawn called after uv_spawn') self._fds_to_close.add(fd) - cdef _dealloc_impl(self): + def __dealloc__(self): if self.uv_opt_env is not NULL: PyMem_RawFree(self.uv_opt_env) self.uv_opt_env = NULL @@ -199,8 +199,6 @@ cdef class UVProcess(UVHandle): PyMem_RawFree(self.uv_opt_args) self.uv_opt_args = NULL - UVHandle._dealloc_impl(self) - cdef char** __to_cstring_array(self, list arr): cdef: int i diff --git a/uvloop/handles/udp.pyx b/uvloop/handles/udp.pyx index 10a4f6dd..86e8fd2e 100644 --- a/uvloop/handles/udp.pyx +++ b/uvloop/handles/udp.pyx @@ -100,18 +100,14 @@ cdef class UDPTransport(UVBaseTransport): udp._init(loop, sock, r_addr) return udp - cdef _dealloc_impl(self): + def __dealloc__(self): + if UVLOOP_DEBUG: + self._loop._debug_uv_handles_freed += 1 + if self._closed == 0: self._warn_unclosed() self._close() - # It is unsafe to call `self.poll._close()` here as - # we might be at the stage where all CPython objects - # are being freed, and `self.poll` points to some - # zombie Python object. So we do nothing. - - UVHandle._dealloc_impl(self) - cdef _free(self): if self.poll is not None: self.poll._close()