From 0e26db9e08b8bb08f836d87ad79cf1f558553c73 Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Sat, 4 Jun 2016 16:05:52 +0100 Subject: [PATCH] correct wording in docstring and tests --- rq/worker.py | 3 ++- tests/fixtures.py | 9 +++++---- tests/test_worker.py | 19 ++++--------------- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/rq/worker.py b/rq/worker.py index dfa70cd..235b8af 100644 --- a/rq/worker.py +++ b/rq/worker.py @@ -732,7 +732,8 @@ class HerokuWorker(Worker): """ Modified version of rq worker which: * stops work horses getting killed with SIGTERM - * sends SIGRTMIN to work horses on SIGTERM to the main process so they can crash as they wish + * sends SIGRTMIN to work horses on SIGTERM to the main process which in turn + causes the horse to crash `imminent_shutdown_delay` seconds later """ imminent_shutdown_delay = 6 frame_properties = ['f_code', 'f_exc_traceback', 'f_exc_type', 'f_exc_value', diff --git a/tests/fixtures.py b/tests/fixtures.py index 6b05ba1..7402e06 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -107,17 +107,18 @@ def long_running_job(timeout=10): def run_dummy_heroku_worker(sandbox, _imminent_shutdown_delay): """ - Run a simplified heroku worker where perform_job job just creates two files 2 seconds apart + Run the work horse for a simplified heroku worker where perform_job just + creates two sentinel files 2 seconds apart. :param sandbox: directory to create files in - :param _imminent_shutdown_delay: delay to use for TestHerokuWorker - :return: + :param _imminent_shutdown_delay: delay to use for HerokuWorker """ class TestHerokuWorker(HerokuWorker): imminent_shutdown_delay = _imminent_shutdown_delay def perform_job(self, job, queue): create_file(os.path.join(sandbox, 'started')) - # have to loop here rather than one sleep to avoid holding the GIL and preventing signals being recieved + # have to loop here rather than one sleep to avoid holding the GIL + # and preventing signals being received for i in range(20): time.sleep(0.1) create_file(os.path.join(sandbox, 'finished')) diff --git a/tests/test_worker.py b/tests/test_worker.py index 6195dc4..7df27f0 100644 --- a/tests/test_worker.py +++ b/tests/test_worker.py @@ -691,19 +691,6 @@ class HerokuWorkerShutdownTestCase(TimeoutTestCase, RQTestCase): def tearDown(self): shutil.rmtree(self.sandbox, ignore_errors=True) - @slow - def test_idle_worker_shutdown(self): - """worker with no ongoing job receiving single SIGTERM signal and shutting down""" - w = HerokuWorker('foo') - self.assertFalse(w._stop_requested) - p = Process(target=kill_worker, args=(os.getpid(), False)) - p.start() - - w.work() - - p.join(1) - self.assertFalse(w._stop_requested) - @slow def test_immediate_shutdown(self): """Heroku work horse shutdown with immediate (0 second) kill""" @@ -752,7 +739,8 @@ class HerokuWorkerShutdownTestCase(TimeoutTestCase, RQTestCase): self.assertFalse(os.path.exists(os.path.join(self.sandbox, 'finished'))) def test_handle_shutdown_request(self): - """Mutate HerokuWorker so _horse_pid refers to an artificial process and test handle_warm_shutdown_request""" + """Mutate HerokuWorker so _horse_pid refers to an artificial process + and test handle_warm_shutdown_request""" w = HerokuWorker('foo') path = os.path.join(self.sandbox, 'shouldnt_exist') @@ -767,7 +755,8 @@ class HerokuWorkerShutdownTestCase(TimeoutTestCase, RQTestCase): self.assertFalse(os.path.exists(path)) def test_handle_shutdown_request_no_horse(self): - """Mutate HerokuWorker so _horse_pid refers to non existent process and test handle_warm_shutdown_request""" + """Mutate HerokuWorker so _horse_pid refers to non existent process + and test handle_warm_shutdown_request""" w = HerokuWorker('foo') w._horse_pid = 19999