Skip to content

Commit b0d4861

Browse files
committed
refactor
1 parent 5ce8c59 commit b0d4861

File tree

5 files changed

+9
-12
lines changed

5 files changed

+9
-12
lines changed

scheduler/helpers/queues/queue_logic.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ def perform_job(job_model: JobModel, connection: ConnectionType) -> Any: # noqa
5151
if job_model.success_callback:
5252
job_model.success_callback(job_model, connection, result)
5353
return result
54-
except:
54+
except Exception as e:
55+
logger.error(f"Job {job_model.name} failed with exception: {e}", exc_info=True)
5556
if job_model.failure_callback:
5657
job_model.failure_callback(job_model, connection, *sys.exc_info())
5758
raise

scheduler/models/task.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,7 @@ def clean_queue(self) -> None:
389389
queue_names = get_queue_names()
390390
if self.queue not in queue_names:
391391
raise ValidationError(
392-
{
393-
"queue": ValidationError(
394-
"Invalid queue, must be one of: {}".format(", ".join(queue_names)), code="invalid"
395-
)
396-
}
392+
{"queue": ValidationError(f"Invalid queue, must be one of: {', '.join(queue_names)}", code="invalid")}
397393
)
398394

399395
def clean_interval_unit(self) -> None:

scheduler/tests/test_job_arg_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def test__repr__int_val(self):
157157
def test__repr__datetime_val(self):
158158
_time = timezone.now()
159159
kwarg = taskarg_factory(self.TaskArgClass, key="key", arg_type="datetime", val=str(_time))
160-
self.assertEqual("('key', {})".format(repr(_time)), repr(kwarg.value()))
160+
self.assertEqual(f"('key', {repr(_time)})", repr(kwarg.value()))
161161

162162
def test__repr__bool_val(self):
163163
kwarg = taskarg_factory(self.TaskArgClass, key="key", arg_type="bool", val="True")

scheduler/tests/test_task_types/test_task_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def test_callable_args_and_kwargs(self):
245245
queue = get_queue("default")
246246
self.assertEqual(
247247
perform_job(entry, connection=queue.connection),
248-
"test_args_kwargs('one', key1=2, key2={}, key3=False)".format(date),
248+
f"test_args_kwargs('one', key1=2, key2={date}, key3=False)",
249249
)
250250

251251
def test_function_string(self):

scheduler/timeouts.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ def cancel_death_penalty(self):
5454

5555
class UnixSignalDeathPenalty(BaseDeathPenalty):
5656
def handle_death_penalty(self, signum, frame) -> None:
57-
raise self._exception("Task exceeded maximum timeout value ({0} seconds)".format(self._timeout))
57+
raise self._exception(f"Task exceeded maximum timeout value ({self._timeout} seconds)")
5858

5959
def setup_death_penalty(self) -> None:
60-
"""Sets up an alarm signal and a signal handler that raises an exception after the timeout amount (expressed
61-
in seconds)."""
60+
"""Sets up an alarm signal and a signal handler that raises an exception after the timeout amount
61+
(expressed in seconds)."""
6262
signal.signal(signal.SIGALRM, self.handle_death_penalty)
6363
signal.alarm(self._timeout)
6464

@@ -77,7 +77,7 @@ def __init__(self, timeout, exception=JobTimeoutException, **kwargs):
7777
# Monkey-patch exception with the message ahead of time
7878
# since PyThreadState_SetAsyncExc can only take a class
7979
def init_with_message(self, *args, **kwargs): # noqa
80-
super(exception, self).__init__("Task exceeded maximum timeout value ({0} seconds)".format(timeout))
80+
super(exception, self).__init__(f"Task exceeded maximum timeout value ({timeout} seconds)")
8181

8282
self._exception.__init__ = init_with_message
8383

0 commit comments

Comments
 (0)