Skip to content

Commit 319ac9f

Browse files
authored
Fixed shutdowns. (#425)
1 parent f6c96b2 commit 319ac9f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

taskiq/cli/worker/run.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ async def shutdown_broker(broker: AsyncBroker, timeout: float) -> None:
4444
try:
4545
ret_val = await asyncio.wait_for(broker.shutdown(), timeout) # type: ignore
4646
if ret_val is not None:
47-
logger.info("Broker returned value on shutdown: '%s'", str(ret_val))
47+
logger.info("Broker has returned value on shutdown: '%s'", str(ret_val))
4848
except asyncio.TimeoutError:
49-
logger.warning("Cannot shutdown broker gracefully. Timed out.")
49+
logger.warning("Broker.shutdown cannot be completed in %s seconds.", timeout)
5050
except Exception as exc:
5151
logger.warning(
52-
"Exception found while terminating: %s",
52+
"Exception found while shutting down broker: %s",
5353
exc,
5454
exc_info=True,
5555
)
@@ -151,8 +151,7 @@ def interrupt_handler(signum: int, _frame: Any) -> None:
151151
**receiver_kwargs, # type: ignore
152152
)
153153
loop.run_until_complete(receiver.listen(shutdown_event))
154-
except KeyboardInterrupt:
155-
logger.warning("Worker process interrupted.")
154+
finally:
156155
loop.run_until_complete(shutdown_broker(broker, args.shutdown_timeout))
157156

158157

0 commit comments

Comments
 (0)