summaryrefslogtreecommitdiff
path: root/crocoite/cli.py
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2018-12-22 10:28:11 +0100
committerLars-Dominik Braun <lars@6xq.net>2018-12-22 10:28:11 +0100
commit0b83e60c0b637ee4c9b7f2299dba8742e6b8fc5a (patch)
treeb31e4cd4c491850ccfe235eb4d1de4452065b3c1 /crocoite/cli.py
parent0e176f24e93f02a266470d1a8924f020a3e2ddd5 (diff)
downloadcrocoite-0b83e60c0b637ee4c9b7f2299dba8742e6b8fc5a.tar.gz
crocoite-0b83e60c0b637ee4c9b7f2299dba8742e6b8fc5a.tar.bz2
crocoite-0b83e60c0b637ee4c9b7f2299dba8742e6b8fc5a.zip
Switch -recursive to asyncio’s .cancel()
RecursiveController used a custom .cancel() method before. Instead we can simply cancel .run() and handle the CancelledError inside run() and fetch().
Diffstat (limited to 'crocoite/cli.py')
-rw-r--r--crocoite/cli.py5
1 files changed, 3 insertions, 2 deletions
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