Restructured all the modules

The core module was becoming too large.
By splitting it in  cluster, monitor and tasks it becomes more manageable. It also reflects the documentation structure.
This commit is contained in:
Ilan Steemers
2015-07-03 15:12:11 +02:00
parent b378d18098
commit b113a52825
13 changed files with 399 additions and 361 deletions
+2 -2
View File
@@ -4,8 +4,8 @@ from django.utils import timezone
import pytest
from django_q import Task, schedule
from django_q.models import Failure
from django_q.tasks import schedule
from django_q.models import Task, Failure
@pytest.mark.django_db
+13 -12
View File
@@ -8,11 +8,12 @@ import pytest
myPath = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, myPath + '/../')
from django_q.core import Cluster, async, pusher, worker, monitor, redis_client, Sentinel
from django_q.cluster import Cluster, Sentinel, pusher, worker, monitor
from django_q.humanhash import DEFAULT_WORDLIST
from django_q import result, get_task, Task
from django_q.tests.tasks import multiply
from django_q.conf import Conf
from django_q.tasks import fetch, async, result
from django_q.models import Task
from django_q.conf import Conf, redis_client
from .tasks import multiply
class WordClass(object):
@@ -143,40 +144,40 @@ def test_async(r):
assert result_queue.qsize() == 0
# Check the results
# task a
result_a = get_task(a)
result_a = fetch(a)
assert result_a is not None
assert result_a.success is True
assert result(a) == 1506
# task b
result_b = get_task(b)
result_b = fetch(b)
assert result_b is not None
assert result_b.success is True
assert result(b) == 1506
# task c
result_c = get_task(c)
result_c = fetch(c)
assert result_c is not None
assert result_c.success is False
# task d
result_d = get_task(d)
result_d = fetch(d)
assert result_d is not None
assert result_d.success is False
# task e
result_e = get_task(e)
result_e = fetch(e)
assert result_e is not None
assert result_e.success is True
assert result(e) is None
# task f
result_f = get_task(f)
result_f = fetch(f)
assert result_f is not None
assert result_f.success is True
assert result(f) == 1506
# task g
result_g = get_task(g)
result_g = fetch(g)
assert result_g is not None
assert result_g.success is True
assert result(g) == 'John'
# task h
result_h = get_task(h)
result_h = fetch(h)
assert result_h is not None
assert result_h.success is True
assert result(h) == 12
+2 -2
View File
@@ -1,5 +1,5 @@
from django_q.core import Cluster
from django_q.management.commands.qmonitor import monitor
from django_q.cluster import Cluster
from django_q.monitor import monitor
def test_monitor():
+4 -3
View File
@@ -2,8 +2,9 @@ from multiprocessing import Queue, Event, Value
import pytest
from django_q.core import scheduler, pusher, worker, monitor, redis_client, schedule as create_schedule
from django_q import Schedule, get_task
from django_q.conf import redis_client
from django_q.cluster import pusher, worker, monitor, scheduler
from django_q.tasks import Schedule, fetch, schedule as create_schedule
@pytest.fixture
@@ -44,7 +45,7 @@ def test_scheduler(r):
assert schedule.repeats == 0
assert schedule.last_run() is not None
assert schedule.success() is True
task = get_task(schedule.task)
task = fetch(schedule.task)
assert task is not None
assert task.success is True
assert task.result < 0