MCPcopy Create free account
hub / github.com/crewAIInc/crewAI / run_concurrent

Function run_concurrent

scripts/wharf_runner.py:200–227  ·  view source on GitHub ↗

Run separate Flow instances; nested agents share only their own run.

(topic: str, runs: int = 3)

Source from the content-addressed store, hash-verified

198
199
200async def run_concurrent(topic: str, runs: int = 3) -> list[RunResult]:
201 """Run separate Flow instances; nested agents share only their own run."""
202 if runs < 1:
203 raise ValueError("runs must be at least 1")
204 if get_execution_uuid() is not None:
205 raise ValueError("Start independent runs outside an active execution session")
206
207 async def run_one(number: int) -> RunResult:
208 flow = WharfDemoFlow(tracing=True)
209 output, error = "", None
210 try:
211 result = await flow.kickoff_async(
212 inputs={"topic": topic, "run_number": number}
213 )
214 if not isinstance(result, str):
215 raise TypeError("Expected the Flow to return a summary string")
216 output = result
217 except Exception as exc:
218 error = f"{type(exc).__name__}: {exc}"
219 return RunResult(
220 run_number=number,
221 execution_uuid=flow.state.execution_uuid,
222 trace_id=flow.state.trace_id,
223 output=output,
224 error=error,
225 )
226
227 return await asyncio.gather(*(run_one(number) for number in range(1, runs + 1)))
228
229
230def main() -> int:

Callers 1

mainFunction · 0.85

Calls 3

get_execution_uuidFunction · 0.90
run_oneFunction · 0.85
gatherMethod · 0.45

Tested by

no test coverage detected