diff --git a/rq/cli/cli.py b/rq/cli/cli.py index b3573e98d..fb0dc8e59 100755 --- a/rq/cli/cli.py +++ b/rq/cli/cli.py @@ -153,8 +153,8 @@ def info(url, config, path, interval, raw, only_queues, only_workers, by_queue, @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, connection_class, path, results_ttl, worker_ttl, - verbose, quiet, sentry_dsn, exception_handler, pid, queues): +def worker(url, config, burst, name, worker_class, job_class, queue_class, connection_class, path, results_ttl, + worker_ttl, verbose, quiet, sentry_dsn, exception_handler, pid, queues): """Starts an RQ worker.""" if path: diff --git a/rq/job.py b/rq/job.py index ce1894b13..133a74859 100644 --- a/rq/job.py +++ b/rq/job.py @@ -579,4 +579,5 @@ def __eq__(self, other): # noqa def __hash__(self): return hash(self.id) + _job_stack = LocalStack() diff --git a/rq/worker.py b/rq/worker.py index 95bcded3e..3067f68ea 100644 --- a/rq/worker.py +++ b/rq/worker.py @@ -55,6 +55,7 @@ def iterable(x): def compact(l): return [x for x in l if x is not None] + _signames = dict((getattr(signal, signame), signame) for signame in dir(signal) if signame.startswith('SIG') and '_' not in signame) @@ -544,7 +545,7 @@ def monitor_work_horse(self, job): except Exception: pass - #Unhandled failure: move the job to the failed queue + # Unhandled failure: move the job to the failed queue self.log.warning( 'Moving job to {0!r} queue'.format( self.failed_queue.name @@ -826,7 +827,7 @@ def request_stop_sigrtmin(self, signum, frame): self.request_force_stop_sigrtmin(signum, frame) else: self.log.warning('Imminent shutdown, raising ShutDownImminentException in %d seconds', - self.imminent_shutdown_delay) + self.imminent_shutdown_delay) signal.signal(signal.SIGRTMIN, self.request_force_stop_sigrtmin) signal.signal(signal.SIGALRM, self.request_force_stop_sigrtmin) signal.alarm(self.imminent_shutdown_delay) diff --git a/tests/test_worker.py b/tests/test_worker.py index b753274f5..492337980 100644 --- a/tests/test_worker.py +++ b/tests/test_worker.py @@ -577,6 +577,7 @@ def kill_worker(pid, double_kill): time.sleep(0.5) os.kill(pid, signal.SIGTERM) + def wait_and_kill_work_horse(pid, time_to_wait=0.0): time.sleep(time_to_wait) os.kill(pid, signal.SIGKILL) @@ -678,6 +679,7 @@ def test_work_horse_death_sets_job_failed(self): self.assertEqual(failed_q.count, 1) self.assertEqual(fooq.count, 0) + def schedule_access_self(): q = Queue('default', connection=get_current_connection()) q.enqueue(access_self)