arrayqueues icon indicating copy to clipboard operation
arrayqueues copied to clipboard

Supporting timeout

Open thomashirtz opened this issue 2 years ago • 1 comments

Hello! I wanted to know, when adding an element to a queue that is full, like in this test:

def test():
    shape = (100, 100)
    num_elements = 10

    data = np.random.random(size=shape)
    mbytes = data.nbytes/1_000_000*num_elements

    queue = ArrayQueue(max_mbytes=mbytes)
    for i in range(2*num_elements):
        print(i)
        queue.put(data)

Instead of throwing an error :

Traceback (most recent call last):
  File "D:/Thomas/Python/treequeues/test_treequeues.py", line 99, in <module>
    test()
  File "D:/Thomas/Python/treequeues/test_treequeues.py", line 77, in test
    queue.put(data)
  File "D:\Thomas\Python\treequeues\venv\lib\site-packages\arrayqueues\shared_arrays.py", line 87, in put
    self.check_full()
  File "D:\Thomas\Python\treequeues\venv\lib\site-packages\arrayqueues\shared_arrays.py", line 73, in check_full
    raise Full(
queue.Full: Queue of length 10 full when trying to insert 0, last item read was 0

Would it be possible to be able to hang like multprocessing queue ?

thomashirtz avatar Apr 09 '22 13:04 thomashirtz