Moved multiqueue to network module

This commit is contained in:
anand k 2024-06-23 08:43:51 +05:30
parent 27e566140d
commit 6578b5b925
No known key found for this signature in database
GPG Key ID: 515AC24FA525DDE0
3 changed files with 6 additions and 12 deletions

View File

@ -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

View File

@ -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):

View File

@ -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):