From 57cc486bf5490054545449e6c2f267be1e7ea98c Mon Sep 17 00:00:00 2001 From: Andy Dirnberger Date: Mon, 2 May 2016 15:46:56 -0400 Subject: [PATCH] Support the command line debug flag Henson's debug mode was added in bea66d9. Unfortunately the command line's debug flag was never passed along to `Application.run_forever`. With this change it will now be passed. Enabling debug mode through the command line will also enable the reloader. --- docs/index.rst | 4 ++++ henson/cli.py | 11 ++++++----- tests/conftest.py | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index b421b45..5e1dc9f 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -87,6 +87,10 @@ option:: $ python -m henson run file_printer --debug +.. note:: The ``--debug`` option is not recommended for production use. + +This will also enable the reloader. + Logging ======= diff --git a/henson/cli.py b/henson/cli.py index 82ec6a9..188eae7 100644 --- a/henson/cli.py +++ b/henson/cli.py @@ -97,9 +97,10 @@ def run(application_path, reloader=False, workers=1, debug=False): app_name, app = app_candidates[0] - if reloader: - # If the reloader is requested, create threads for running the - # application and watching the file system for changes + if reloader or debug: + # If the reloader is requested (or debug is enabled), create + # threads for running the application and watching the file + # system for changes. print('Running {}.{} with reloader...'.format( import_path, app_name, @@ -115,7 +116,7 @@ def run(application_path, reloader=False, workers=1, debug=False): loop = asyncio.new_event_loop() runner = Thread( target=app.run_forever, - kwargs={'num_workers': workers, 'loop': loop}, + kwargs={'num_workers': workers, 'loop': loop, 'debug': debug}, ) # This function is called by watchdog event handler when changes @@ -139,7 +140,7 @@ def restart_process(event): else: # If the reloader is not needed, avoid the overhead print('Running {}.{} forever ...'.format(import_path, app_name)) - app.run_forever(num_workers=workers) + app.run_forever(num_workers=workers, debug=debug) def main(): diff --git a/tests/conftest.py b/tests/conftest.py index d44f078..aa565af 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -20,7 +20,7 @@ def __init__(self, **settings): super().__init__('testing') self.settings = settings - def run_forever(self, num_workers=1, loop=None): + def run_forever(self, num_workers=1, loop=None, debug=False): """Run the instance.""" print('Run, Forrest, run!')