summaryrefslogtreecommitdiff
path: root/rq/cli/cli.py
diff options
context:
space:
mode:
authorBradley Young <young.bradley@gmail.com>2014-11-12 09:04:40 -0500
committerBradley Young <young.bradley@gmail.com>2014-11-12 09:04:40 -0500
commit5caccaabfe213e98a5a03a6f5914662d8c322134 (patch)
tree7edb9807dac4d0ceeb6e7230c715140508ba6390 /rq/cli/cli.py
parent0dbe68527ce029b5fd0a51d229344322d81f149e (diff)
downloadrq-5caccaabfe213e98a5a03a6f5914662d8c322134.tar.gz
Adding optional list handling to the exc_handler option in Worker.
Adding command line --exception_handler option (with multiple entries allowed) to `rq worker` Added tests for command line options.
Diffstat (limited to 'rq/cli/cli.py')
-rwxr-xr-xrq/cli/cli.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/rq/cli/cli.py b/rq/cli/cli.py
index 18979dc..d5fc1a1 100755
--- a/rq/cli/cli.py
+++ b/rq/cli/cli.py
@@ -132,10 +132,11 @@ def info(url, path, interval, raw, only_queues, only_workers, by_queue, queues):
@click.option('--verbose', '-v', is_flag=True, help='Show more output')
@click.option('--quiet', '-q', is_flag=True, help='Show less output')
@click.option('--sentry-dsn', envvar='SENTRY_DSN', help='Report exceptions to this Sentry DSN')
+@click.option('--exception-handler', help='Exception handler(s) to use', multiple=True)
@click.option('--pid', help='Write the process ID number to a file at the specified path')
@click.argument('queues', nargs=-1)
def worker(url, config, burst, name, worker_class, job_class, queue_class, path, results_ttl, worker_ttl,
- verbose, quiet, sentry_dsn, pid, queues):
+ verbose, quiet, sentry_dsn, exception_handler, pid, queues):
"""Starts an RQ worker."""
if path:
@@ -157,6 +158,9 @@ def worker(url, config, burst, name, worker_class, job_class, queue_class, path,
cleanup_ghosts(conn)
worker_class = import_attribute(worker_class)
queue_class = import_attribute(queue_class)
+ exc_handler = []
+ for h in exception_handler:
+ exc_handler.append(import_attribute(h))
try:
queues = [queue_class(queue, connection=conn) for queue in queues]
@@ -165,7 +169,8 @@ def worker(url, config, burst, name, worker_class, job_class, queue_class, path,
connection=conn,
default_worker_ttl=worker_ttl,
default_result_ttl=results_ttl,
- job_class=job_class)
+ job_class=job_class,
+ exc_handler=exc_handler)
# Should we configure Sentry?
if sentry_dsn: