(self, items)
| 227 | return result |
| 228 | |
| 229 | async def parallel(self, items) -> list: |
| 230 | items = list(items) |
| 231 | if len(items) > MAX_ITEMS_PER_CALL: |
| 232 | self._close_coroutines(items) |
| 233 | raise WorkflowError( |
| 234 | f"parallel() received {len(items)} items; the per-call cap is {MAX_ITEMS_PER_CALL}" |
| 235 | ) |
| 236 | base = current_branch().path + (current_branch().next_slot(),) |
| 237 | |
| 238 | async def guarded(index: int, item): |
| 239 | token = use_branch(base + (index,)) |
| 240 | try: |
| 241 | return await await_item(item) |
| 242 | except Exception: |
| 243 | return None # the barrier never rejects |
| 244 | finally: |
| 245 | reset_branch(token) |
| 246 | |
| 247 | return list(await asyncio.gather(*(guarded(i, it) for i, it in enumerate(items)))) |
| 248 | |
| 249 | async def pipeline(self, items, *stages) -> list: |
| 250 | items = list(items) |
nothing calls this directly
no test coverage detected