Moved Multiqueue, invQueue and addrQueue to network module #2256
|
@ -2,16 +2,11 @@
|
||||||
A queue with multiple internal subqueues.
|
A queue with multiple internal subqueues.
|
||||||
Elements are added into a random subqueue, and retrieval rotates
|
Elements are added into a random subqueue, and retrieval rotates
|
||||||
"""
|
"""
|
||||||
|
import random
|
||||||
from collections import deque
|
from collections import deque
|
||||||
|
|
||||||
from six.moves import queue
|
from six.moves import queue
|
||||||
|
|
||||||
try:
|
|
||||||
import helper_random
|
|
||||||
except ImportError:
|
|
||||||
from . import helper_random
|
|
||||||
|
|
||||||
|
|
||||||
class MultiQueue(queue.Queue):
|
class MultiQueue(queue.Queue):
|
||||||
"""A base queue class"""
|
"""A base queue class"""
|
||||||
|
@ -38,7 +33,7 @@ class MultiQueue(queue.Queue):
|
||||||
# Put a new item in the queue
|
# Put a new item in the queue
|
||||||
def _put(self, item):
|
def _put(self, item):
|
||||||
# self.queue.append(item)
|
# self.queue.append(item)
|
||||||
self.queues[helper_random.randomrandrange(self.queueCount)].append(
|
self.queues[random.randrange(self.queueCount)].append( # nosec B311
|
||||||
(item))
|
(item))
|
||||||
|
|
||||||
# Get an item from the queue
|
# Get an item from the queue
|
|
@ -5,10 +5,9 @@ import time
|
||||||
|
|
||||||
from six.moves import queue
|
from six.moves import queue
|
||||||
|
|
||||||
try:
|
|
||||||
from multiqueue import MultiQueue
|
from network.multiqueue import MultiQueue
|
||||||
except ImportError:
|
|
||||||
from .multiqueue import MultiQueue
|
|
||||||
|
|
||||||
|
|
||||||
class ObjectProcessorQueue(queue.Queue):
|
class ObjectProcessorQueue(queue.Queue):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""Test cases for multiqueue"""
|
"""Test cases for multiqueue"""
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
from pybitmessage.multiqueue import MultiQueue
|
from pybitmessage.network.multiqueue import MultiQueue
|
||||||
|
|
||||||
|
|
||||||
class TestMultiQueue(unittest.TestCase):
|
class TestMultiQueue(unittest.TestCase):
|
||||||
|
|
Reference in New Issue
Block a user