Method
_invoke_graph
(self, graph: Any, state: Any, recursion_limit: int)
Source from the content-addressed store, hash-verified
| 150 | return "failed" |
| 151 | |
| 152 | def _invoke_graph(self, graph: Any, state: Any, recursion_limit: int) -> Any: |
| 153 | try: |
| 154 | import nest_asyncio |
| 155 | |
| 156 | nest_asyncio.apply() |
| 157 | except ImportError: |
| 158 | pass |
| 159 | |
| 160 | coro = graph.ainvoke(state, config={"recursion_limit": recursion_limit}) |
| 161 | try: |
| 162 | return asyncio.run(coro) |
| 163 | except RuntimeError as exc: |
| 164 | if "asyncio.run() cannot be called from a running event loop" not in str(exc): |
| 165 | raise |
| 166 | loop = asyncio.get_event_loop() |
| 167 | return loop.run_until_complete(coro) |
Tested by
no test coverage detected