Skip to content

Commit

Permalink
Support the command line debug flag
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dirn committed May 2, 2016
1 parent d4420f7 commit 57cc486
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
=======

Expand Down
11 changes: 6 additions & 5 deletions henson/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!')

Expand Down

0 comments on commit 57cc486

Please sign in to comment.