forked from tangger/lerobot
fix(hil-serl): drain queue on get_last_item_from_queue (#1524)
* fix(hil-serl): drain queue on get_last_item_from_queue * parametrize queue tests * revert changes for Darwin * revert parametrize queue tests * add test_get_last_item_multiple_items_with_torch_queue * update test_get_last_item_multiple_items_with_torch_queue * update test_get_last_item_multiple_items_with_torch_queue
This commit is contained in:
@@ -18,6 +18,8 @@ import threading
|
||||
import time
|
||||
from queue import Queue
|
||||
|
||||
from torch.multiprocessing import Queue as TorchMPQueue
|
||||
|
||||
from lerobot.utils.queue import get_last_item_from_queue
|
||||
|
||||
|
||||
@@ -46,6 +48,20 @@ def test_get_last_item_multiple_items():
|
||||
assert queue.empty()
|
||||
|
||||
|
||||
def test_get_last_item_multiple_items_with_torch_queue():
|
||||
"""Test getting the last item when queue has multiple items."""
|
||||
queue = TorchMPQueue()
|
||||
items = ["first", "second", "third", "fourth", "last"]
|
||||
|
||||
for item in items:
|
||||
queue.put(item)
|
||||
|
||||
result = get_last_item_from_queue(queue)
|
||||
|
||||
assert result == "last"
|
||||
assert queue.empty()
|
||||
|
||||
|
||||
def test_get_last_item_different_types():
|
||||
"""Test with different data types in the queue."""
|
||||
queue = Queue()
|
||||
|
||||
Reference in New Issue
Block a user