Import python3 version of range

This commit is contained in:
Benjamin Bach
2017-07-09 21:44:25 +02:00
parent ab48bad0f6
commit 5ea55e3718
6 changed files with 20 additions and 2 deletions

View File

@@ -4,8 +4,6 @@ from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from builtins import range
# Standard
import importlib
import signal
@@ -26,6 +24,7 @@ from django import db
import signing
import tasks
from django_q.compat import range
from django_q.conf import Conf, logger, psutil, get_ppid, rollbar
from django_q.models import Task, Success, Schedule
from django_q.status import Stat, Status
@@ -33,6 +32,7 @@ from django_q.brokers import get_broker
from django_q.signals import pre_execute
class Cluster(object):
def __init__(self, broker=None):
self.broker = broker or get_broker()

14
django_q/compat.py Normal file
View File

@@ -0,0 +1,14 @@
from __future__ import absolute_import
"""
Compatibility layer.
Intentionally replaces use of python-future
"""
# https://github.com/Koed00/django-q/issues/4
try:
range = xrange
except NameError:
range = range

View File

@@ -5,6 +5,7 @@ import pytest
import redis
from django_q.brokers import get_broker, Broker
from django_q.compat import range
from django_q.conf import Conf
from django_q.humanhash import uuid

View File

@@ -3,6 +3,7 @@ from multiprocessing import Event, Queue, Value
import pytest
from django_q.cluster import pusher, worker, monitor
from django_q.compat import range
from django_q.conf import Conf
from django_q.tasks import async, result, fetch, count_group, result_group, fetch_group, delete_group, delete_cached, \
async_iter, Chain, async_chain, Iter, Async

View File

@@ -11,6 +11,7 @@ myPath = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, myPath + '/../')
from django_q.cluster import Cluster, Sentinel, pusher, worker, monitor, save_task
from django_q.compat import range
from django_q.humanhash import DEFAULT_WORDLIST, uuid
from django_q.tasks import fetch, fetch_group, async, result, result_group, count_group, delete_group, queue_size
from django_q.models import Task, Success

View File

@@ -3,6 +3,7 @@ import pytest
from django_q.tasks import async
from django_q.brokers import get_broker
from django_q.cluster import Cluster
from django_q.compat import range
from django_q.monitor import monitor, info
from django_q.status import Stat
from django_q.conf import Conf