diff options
author | Dana Powers <dana.powers@rd.io> | 2016-01-03 19:50:21 -0800 |
---|---|---|
committer | Dana Powers <dana.powers@rd.io> | 2016-01-03 22:10:25 -0800 |
commit | 03d37dff5c707599e2f268dccb4cccafbeadd5e3 (patch) | |
tree | abb10310c48cb06a4e01bb47f38e7e4f0cd31240 | |
parent | ed8f2212bf879831d38300212aa2251e4c4f0d8c (diff) | |
download | kafka-python-03d37dff5c707599e2f268dccb4cccafbeadd5e3.tar.gz |
Import queue from six.moves
-rw-r--r-- | kafka/consumer/multiprocess.py | 6 | ||||
-rw-r--r-- | kafka/consumer/simple.py | 5 | ||||
-rw-r--r-- | test/test_producer.py | 13 |
3 files changed, 6 insertions, 18 deletions
diff --git a/kafka/consumer/multiprocess.py b/kafka/consumer/multiprocess.py index d0e2920..a348d1a 100644 --- a/kafka/consumer/multiprocess.py +++ b/kafka/consumer/multiprocess.py @@ -3,12 +3,10 @@ from __future__ import absolute_import from collections import namedtuple import logging from multiprocessing import Process, Manager as MPManager -try: - import queue # python 3 -except ImportError: - import Queue as queue # python 2 import time +from six.moves import queue + from ..common import KafkaError from .base import ( Consumer, diff --git a/kafka/consumer/simple.py b/kafka/consumer/simple.py index 946e9c7..abeac7b 100644 --- a/kafka/consumer/simple.py +++ b/kafka/consumer/simple.py @@ -5,14 +5,11 @@ try: except ImportError: from itertools import izip_longest as izip_longest, repeat # pylint: disable=E0611 import logging -try: - import queue # python 3 -except ImportError: - import Queue as queue # python 2 import sys import time import six +from six.moves import queue from .base import ( Consumer, diff --git a/test/test_producer.py b/test/test_producer.py index f62b97a..227d4ad 100644 --- a/test/test_producer.py +++ b/test/test_producer.py @@ -2,6 +2,7 @@ import collections import logging +import threading import time from mock import MagicMock, patch @@ -15,15 +16,7 @@ from kafka.common import ( from kafka.producer.base import Producer, _send_upstream from kafka.protocol import CODEC_NONE -import threading -try: - from queue import Empty, Queue -except ImportError: - from Queue import Empty, Queue -try: - xrange -except NameError: - xrange = range +from six.moves import queue, xrange class TestKafkaProducer(unittest.TestCase): @@ -130,7 +123,7 @@ class TestKafkaProducerSendUpstream(unittest.TestCase): def setUp(self): self.client = MagicMock() - self.queue = Queue() + self.queue = queue.Queue() def _run_process(self, retries_limit=3, sleep_timeout=1): # run _send_upstream process with the queue |