Skip to content

Commit fbd7eb0

Browse files
committed
Modernise Python style/imports
1 parent 3f49bd5 commit fbd7eb0

File tree

12 files changed

+20
-21
lines changed

12 files changed

+20
-21
lines changed

django_lightweight_queue/app_settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
from . import constants
44

5+
56
def setting(suffix, default):
67
attr_name = '{}{}'.format(constants.SETTING_NAME_PREFIX, suffix)
78
return getattr(settings, attr_name, default)
89

10+
911
WORKERS = setting('WORKERS', {})
1012
BACKEND = setting('BACKEND', 'django_lightweight_queue.backends.synchronous.SynchronousBackend')
1113

django_lightweight_queue/apps.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from .utils import load_all_tasks
44

5+
56
class DjangoLightweightQueueConfig(AppConfig):
67
name = 'django_lightweight_queue'
78

django_lightweight_queue/backends/redis.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import # For 'redis'
2-
31
import redis
42

53
from ..job import Job
@@ -9,6 +7,7 @@ class RedisBackend(object):
97
"""
108
This backend has at-most-once semantics.
119
"""
10+
1211
def __init__(self):
1312
self.client = redis.StrictRedis(
1413
host=app_settings.REDIS_HOST,

django_lightweight_queue/backends/reliable_redis.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import # For 'redis'
2-
31
import redis
42

53
from ..job import Job

django_lightweight_queue/cron_scheduler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def get_matcher(minval, maxval, t):
127127
for row in mod.CONFIG:
128128
row['min_matcher'] = get_matcher(0, 59, row.get('minutes'))
129129
row['hour_matcher'] = get_matcher(0, 23, row.get('hours'))
130-
row['day_matcher'] = get_matcher(1, 7, row.get('days', '*'))
130+
row['day_matcher'] = get_matcher(1, 7, row.get('days', '*'))
131131
row['queue'] = row.get('queue', 'cron')
132132
row['timeout'] = row.get('timeout', None)
133133
row['sigkill_on_stop'] = row.get('sigkill_on_stop', False)

django_lightweight_queue/exposition.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import json
22
import threading
3-
43
from socket import gethostname
5-
6-
try:
7-
from http.server import HTTPServer
8-
except ImportError:
9-
from BaseHTTPServer import HTTPServer
4+
from http.server import HTTPServer
105

116
from prometheus_client.exposition import MetricsHandler
127

@@ -30,7 +25,7 @@ def get_config_response(worker_queue_and_counts):
3025
"labels": {
3126
"django_lightweight_queue_worker_queue": queue,
3227
"django_lightweight_queue_worker_num": str(worker_num),
33-
}
28+
},
3429
}
3530
for index, (queue, worker_num) in enumerate(worker_queue_and_counts, start=1)
3631
]

django_lightweight_queue/job.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
TIME_FORMAT = '%Y-%m-%d %H:%M:%S.%f'
1212

13-
class Job(object):
13+
14+
class Job:
1415
def __init__(self, path, args, kwargs, timeout=None, sigkill_on_stop=False):
1516
self.path = path
1617
self.args = args

django_lightweight_queue/machine_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from .cron_scheduler import CRON_QUEUE_NAME
66

77

8-
class Machine(object):
8+
class Machine:
99
"""
1010
Dummy machine class to contain documentation.
1111
@@ -72,7 +72,7 @@ def worker_names(self):
7272
continue
7373

7474
for worker_num in range(1, num_workers + 1):
75-
if (job_number % self.machine_count) + 1 == self.machine_number:
75+
if (job_number % self.machine_count) + 1 == self.machine_number: # noqa: S001
7676
worker_names.append((queue, worker_num))
7777

7878
job_number += 1

django_lightweight_queue/middleware/logging.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import
2-
31
import json
42
import logging
53
import traceback

django_lightweight_queue/task.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from . import app_settings
55

6-
class task(object):
6+
class task:
77
def __init__(self, queue='default', timeout=None, sigkill_on_stop=False, atomic=None):
88
"""
99
Define a task to be run.
@@ -71,7 +71,8 @@ def slow_fn(arg):
7171
def __call__(self, fn):
7272
return TaskWrapper(fn, self.queue, self.timeout, self.sigkill_on_stop, self.atomic)
7373

74-
class TaskWrapper(object):
74+
75+
class TaskWrapper:
7576
def __init__(self, fn, queue, timeout, sigkill_on_stop, atomic):
7677
self.fn = fn
7778
self.queue = queue

0 commit comments

Comments
 (0)