mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-07-04 15:41:00 +00:00
21 lines
666 B
Python
21 lines
666 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": 0.001}, {"wait_for": 0.002}]
|
|
|
|
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
|