From 0b83e60c0b637ee4c9b7f2299dba8742e6b8fc5a Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sat, 22 Dec 2018 10:28:11 +0100 Subject: Switch -recursive to asyncio’s .cancel() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RecursiveController used a custom .cancel() method before. Instead we can simply cancel .run() and handle the CancelledError inside run() and fetch(). --- crocoite/cli.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'crocoite/cli.py') diff --git a/crocoite/cli.py b/crocoite/cli.py index b0ad53a..f9ef52c 100644 --- a/crocoite/cli.py +++ b/crocoite/cli.py @@ -120,11 +120,12 @@ def recursive (): tempdir=args.tempdir, prefix=args.prefix, concurrency=args.concurrency) + run = asyncio.ensure_future (controller.run ()) loop = asyncio.get_event_loop() - stop = lambda signum: controller.cancel () + stop = lambda signum: run.cancel () loop.add_signal_handler (signal.SIGINT, stop, signal.SIGINT) loop.add_signal_handler (signal.SIGTERM, stop, signal.SIGTERM) - loop.run_until_complete(controller.run ()) + loop.run_until_complete(run) loop.close() return 0 -- cgit v1.2.3