Skip to content

Commit 9fbb079

Browse files
committed
New method: BaseService.cancel_nowait()
1 parent fd5c5d4 commit 9fbb079

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

p2p/service.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,7 @@ async def cleanup(self) -> None:
187187

188188
self.events.cleaned_up.set()
189189

190-
async def cancel(self) -> None:
191-
"""Trigger the CancelToken and wait for the cleaned_up event to be set."""
190+
def cancel_nowait(self) -> None:
192191
if self.is_cancelled:
193192
self.logger.warning("Tried to cancel %s, but it was already cancelled", self)
194193
return
@@ -198,6 +197,11 @@ async def cancel(self) -> None:
198197
self.logger.debug("Cancelling %s", self)
199198
self.events.cancelled.set()
200199
self.cancel_token.trigger()
200+
201+
async def cancel(self) -> None:
202+
"""Trigger the CancelToken and wait for the cleaned_up event to be set."""
203+
self.cancel_nowait()
204+
201205
try:
202206
await asyncio.wait_for(
203207
self.events.cleaned_up.wait(), timeout=self._wait_until_finished_timeout)

0 commit comments

Comments
 (0)