From 46b5cf64c348423b253ec86a99c9bcd972478345 Mon Sep 17 00:00:00 2001 From: Selwin Ong Date: Tue, 14 Feb 2023 07:47:52 +0700 Subject: [PATCH] Added black config (#1815) --- pyproject.toml | 4 ++++ rq/worker.py | 13 ++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..4787b13 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,4 @@ +[tool.black] +line-length = 120 +target-version = ['py36'] +skip-string-normalization = true \ No newline at end of file diff --git a/rq/worker.py b/rq/worker.py index a324ad6..4475d49 100644 --- a/rq/worker.py +++ b/rq/worker.py @@ -234,7 +234,6 @@ class Worker: prepare_for_work: bool = True, serializer=None, ): # noqa - self.default_result_ttl = default_result_ttl self.worker_ttl = default_worker_ttl self.job_monitoring_interval = job_monitoring_interval @@ -532,8 +531,7 @@ class Worker: return self.job_class.fetch(job_id, self.connection, self.serializer) def _install_signal_handlers(self): - """Installs signal handlers for handling SIGINT and SIGTERM gracefully. - """ + """Installs signal handlers for handling SIGINT and SIGTERM gracefully.""" signal.signal(signal.SIGINT, self.request_stop) signal.signal(signal.SIGTERM, self.request_stop) @@ -621,13 +619,11 @@ class Worker: self.log.info('Warm shut down requested') def check_for_suspension(self, burst: bool): - """Check to see if workers have been suspended by `rq suspend` - """ + """Check to see if workers have been suspended by `rq suspend`""" before_state = None notified = False while not self._stop_requested and is_suspended(self.connection, self): - if burst: self.log.info('Suspended in burst mode, exiting') self.log.info('Note: There could still be unfinished jobs on the queue') @@ -680,7 +676,7 @@ class Worker: Args: reference_queue (Union[Queue, str]): The queue - """ + """ pass def work( @@ -787,7 +783,6 @@ class Worker: break finally: if not self.is_horse: - if self.scheduler: self.stop_scheduler() @@ -822,7 +817,6 @@ class Worker: self.log.debug('*** Listening on %s...', green(qnames)) connection_wait_time = 1.0 while True: - try: self.heartbeat() @@ -1490,6 +1484,7 @@ class HerokuWorker(Worker): * 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_lasti', 'f_lineno', 'f_locals', 'f_trace']