From 430c177b9241d654847481a0641ff973bfe6da3c Mon Sep 17 00:00:00 2001 From: Eagllus Date: Tue, 13 Mar 2018 09:37:13 +0100 Subject: [PATCH] Move import to the function that uses it Only Python 2.x is having problems with this import so for now the fix would be to move the import to the function that uses cluster --- django_q/tasks.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/django_q/tasks.py b/django_q/tasks.py index 96a43fd..bf94a2a 100644 --- a/django_q/tasks.py +++ b/django_q/tasks.py @@ -9,7 +9,6 @@ from django.utils import timezone # local from django_q.signing import SignedPackage -from django_q import cluster from django_q.conf import Conf, logger from django_q.models import Schedule, Task from django_q.humanhash import uuid @@ -672,13 +671,17 @@ class Async(object): def _sync(pack): + # Python 2.6 is unable to handle this import on top of the file + # because it creates a circular dependency between tasks and cluster + from django_q.cluster import worker, monitor + """Simulate a package travelling through the cluster.""" task_queue = Queue() result_queue = Queue() task = SignedPackage.loads(pack) task_queue.put(task) task_queue.put('STOP') - cluster.worker(task_queue, result_queue, Value('f', -1)) + worker(task_queue, result_queue, Value('f', -1)) result_queue.put('STOP') - cluster.monitor(result_queue) + monitor(result_queue) return task['id']