mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-06-26 22:00:13 +00:00
21 lines
658 B
Python
21 lines
658 B
Python
![]() |
import asyncio
|
||
|
|
||
|
from haystack import AsyncPipeline
|
||
|
|
||
|
|
||
|
def test_async_pipeline_reentrance(waiting_component, spying_tracer):
|
||
|
pp = AsyncPipeline()
|
||
|
pp.add_component("wait", waiting_component())
|
||
|
|
||
|
run_data = [{"wait_for": 1}, {"wait_for": 2}]
|
||
|
|
||
|
async def run_all():
|
||
|
# Create concurrent tasks for each pipeline run
|
||
|
tasks = [pp.run_async(data) for data in run_data]
|
||
|
await asyncio.gather(*tasks)
|
||
|
|
||
|
asyncio.run(run_all())
|
||
|
component_spans = [sp for sp in spying_tracer.spans if sp.operation_name == "haystack.component.run_async"]
|
||
|
for span in component_spans:
|
||
|
assert span.tags["haystack.component.visits"] == 1
|