Skip to content

Commit 30222d1

Browse files
authored
fix: missing edge case: semi_ordered_map with empty stream
1 parent d46931c commit 30222d1

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

tests/test_parallel_processor.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ def test_ordered_map_empty():
102102
pool = ParallelWorkerPool(worker=SquareWorker, config=PoolConfig(num_workers=2))
103103
results = list(pool.ordered_map([]))
104104
assert results == []
105+
# Verify processes are joined and list is cleared
106+
assert len(pool.processes) == 0
105107

106108

107109
def test_ordered_map_generator():
@@ -635,3 +637,13 @@ def test_get_items_from_queue_error_handling():
635637

636638
with pytest.raises(Exception, match="Queue error"):
637639
list(_get_items_from_queue(mock_queue))
640+
641+
642+
def test_semi_ordered_map_empty():
643+
"""Test semi_ordered_map with an empty stream."""
644+
pool = ParallelWorkerPool(worker=SquareWorker, config=PoolConfig(num_workers=2))
645+
stream = []
646+
result = list(pool.semi_ordered_map(stream))
647+
assert result == []
648+
# Verify processes are joined and list is cleared
649+
assert len(pool.processes) == 0

0 commit comments

Comments
 (0)