mirror of https://github.com/hwchase17/langchain
Fix Async Retry Event Handling (#8659)
It fails currently because the event loop is already running. The `retry` decorator alraedy infers an `AsyncRetrying` handler for coroutines (see [tenacity line](pull/7915/head^2aa6f8f0a24/tenacity/__init__.py (L535)
)) However before_sleep always gets called synchronously (see [tenacity line](aa6f8f0a24/tenacity/__init__.py (L338)
)). Instead, check for a running loop and use that it exists. Of course, it's running an async method synchronously which is not _nice_. Given how important LLMs are, it may make sense to have a task list or something but I'd want to chat with @nfcampos on where that would live. This PR also fixes the unit tests to check the handler is called and to make sure the async test is run (it looks like it's just been being skipped). It would have failed prior to the proposed fixes but passes now.
parent
8ef7e14a85
commit
f81e613086
Loading…
Reference in New Issue