Skip to content

Commit

Permalink
Update _debug.pyx
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Dec 16, 2024
1 parent 152a45c commit b18dcfa
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions a_sync/primitives/_debug.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,14 @@ cdef class _DebugDaemonMixin(_LoopBoundMixin):
if self._has_daemon:
return

cdef object daemon = self._daemon
if daemon is None:
if self.check_debug_logs_enabled():
daemon = self._c_start_debug_daemon(args, kwargs)
daemon.add_done_callback(self._stop_debug_daemon)
else:
daemon = self._c_get_loop().create_future()
if self.check_debug_logs_enabled():
daemon = self._c_start_debug_daemon(args, kwargs)
daemon.add_done_callback(self._stop_debug_daemon)
self._daemon = daemon
self._has_daemon = True
return daemon
else:
self._daemon = self._c_get_loop().create_future()

self._has_daemon = True

def _stop_debug_daemon(self, t: Optional[asyncio.Task] = None) -> None:
"""
Expand All @@ -203,5 +201,6 @@ cdef class _DebugDaemonMixin(_LoopBoundMixin):
"""
if t and t != self._daemon:
raise ValueError(f"{t} is not {self._daemon}")
self._daemon.cancel()
t.cancel()
self._daemon = None
self._has_daemon = False

0 comments on commit b18dcfa

Please sign in to comment.