mirror of
https://github.com/django-q2/django-q2.git
synced 2026-09-15 13:37:56 +08:00
[cleanup] Fix some linting issues
This commit is contained in:
@@ -57,7 +57,6 @@ class Sqs(Broker):
|
|||||||
del(config['aws_region'])
|
del(config['aws_region'])
|
||||||
return Session(**config)
|
return Session(**config)
|
||||||
|
|
||||||
|
|
||||||
def get_queue(self):
|
def get_queue(self):
|
||||||
self.sqs = self.connection.resource('sqs')
|
self.sqs = self.connection.resource('sqs')
|
||||||
return self.sqs.create_queue(QueueName=self.list_key)
|
return self.sqs.create_queue(QueueName=self.list_key)
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ class IronMQBroker(Broker):
|
|||||||
return self.connection.post(task)['ids'][0]
|
return self.connection.post(task)['ids'][0]
|
||||||
|
|
||||||
def dequeue(self):
|
def dequeue(self):
|
||||||
timeout = Conf.RETRY or None
|
timeout = Conf.RETRY or None
|
||||||
tasks = self.connection.get(timeout=timeout, wait=1, max=Conf.BULK)['messages']
|
tasks = self.connection.get(timeout=timeout, wait=1, max=Conf.BULK)['messages']
|
||||||
if tasks:
|
if tasks:
|
||||||
return [(t['id'], t['body']) for t in tasks]
|
return [(t['id'], t['body']) for t in tasks]
|
||||||
|
|
||||||
def ping(self):
|
def ping(self):
|
||||||
return self.connection.name == self.list_key
|
return self.connection.name == self.list_key
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class ORM(Broker):
|
|||||||
|
|
||||||
def dequeue(self):
|
def dequeue(self):
|
||||||
tasks = self.get_connection().filter(key=self.list_key, lock__lt=_timeout())[
|
tasks = self.get_connection().filter(key=self.list_key, lock__lt=_timeout())[
|
||||||
0 : Conf.BULK
|
0: Conf.BULK
|
||||||
]
|
]
|
||||||
if tasks:
|
if tasks:
|
||||||
task_list = []
|
task_list = []
|
||||||
|
|||||||
@@ -7,9 +7,8 @@ from django.db import IntegrityError
|
|||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from multiprocessing import Value
|
from multiprocessing import Value
|
||||||
|
|
||||||
from django_q.brokers import get_broker
|
|
||||||
|
|
||||||
# local
|
# local
|
||||||
|
from django_q.brokers import get_broker
|
||||||
from django_q.conf import Conf, logger
|
from django_q.conf import Conf, logger
|
||||||
from django_q.humanhash import uuid
|
from django_q.humanhash import uuid
|
||||||
from django_q.models import Schedule, Task
|
from django_q.models import Schedule, Task
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ def test_sync(broker):
|
|||||||
task = async_task('django_q.tests.tasks.count_letters', DEFAULT_WORDLIST, broker=broker, sync=True)
|
task = async_task('django_q.tests.tasks.count_letters', DEFAULT_WORDLIST, broker=broker, sync=True)
|
||||||
assert result(task) == 1506
|
assert result(task) == 1506
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_sync_raise_exception(broker):
|
def test_sync_raise_exception(broker):
|
||||||
with pytest.raises(TaskError):
|
with pytest.raises(TaskError):
|
||||||
@@ -401,6 +402,7 @@ def test_update_failed(broker):
|
|||||||
assert saved_task.success is True
|
assert saved_task.success is True
|
||||||
assert saved_task.result == 'result'
|
assert saved_task.result == 'result'
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_acknowledge_failure_override():
|
def test_acknowledge_failure_override():
|
||||||
class VerifyAckMockBroker(Broker):
|
class VerifyAckMockBroker(Broker):
|
||||||
@@ -434,10 +436,12 @@ def test_acknowledge_failure_override():
|
|||||||
|
|
||||||
tag = uuid()
|
tag = uuid()
|
||||||
task_success_ack = task_fail_ack.copy()
|
task_success_ack = task_fail_ack.copy()
|
||||||
task_success_ack.update({'id': tag[1],
|
task_success_ack.update({
|
||||||
'name': tag[0],
|
'id': tag[1],
|
||||||
'ack_id': 'test_success_ack_id',
|
'name': tag[0],
|
||||||
'success': True,})
|
'ack_id': 'test_success_ack_id',
|
||||||
|
'success': True,
|
||||||
|
})
|
||||||
del task_success_ack['ack_failure']
|
del task_success_ack['ack_failure']
|
||||||
|
|
||||||
result_queue = Queue()
|
result_queue = Queue()
|
||||||
@@ -453,6 +457,7 @@ def test_acknowledge_failure_override():
|
|||||||
assert broker.acknowledgements.get('test_fail_no_ack_id') is None
|
assert broker.acknowledgements.get('test_fail_no_ack_id') is None
|
||||||
assert broker.acknowledgements.get('test_success_ack_id') == 1
|
assert broker.acknowledgements.get('test_success_ack_id') == 1
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def assert_result(task):
|
def assert_result(task):
|
||||||
assert task is not None
|
assert task is not None
|
||||||
|
|||||||
Reference in New Issue
Block a user