From b82ca0e1e3f742222a0ac529c2493ca5f9acd75d Mon Sep 17 00:00:00 2001 From: Benjamin Himes Date: Mon, 7 Oct 2024 17:55:38 +0200 Subject: [PATCH] Handle cancelling receiving task before it's initiated --- bittensor_cli/src/bittensor/async_substrate_interface.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bittensor_cli/src/bittensor/async_substrate_interface.py b/bittensor_cli/src/bittensor/async_substrate_interface.py index 464635958..c953d02f5 100644 --- a/bittensor_cli/src/bittensor/async_substrate_interface.py +++ b/bittensor_cli/src/bittensor/async_substrate_interface.py @@ -679,7 +679,10 @@ async def _exit_with_timer(self): async def shutdown(self): async with self._lock: - self._receiving_task.cancel() + try: + self._receiving_task.cancel() + except AttributeError: + pass try: await self._receiving_task except asyncio.CancelledError: