Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aconfig_with_context makes a blocking call #29530

Open
5 tasks done
cbornet opened this issue Jan 31, 2025 · 0 comments
Open
5 tasks done

aconfig_with_context makes a blocking call #29530

cbornet opened this issue Jan 31, 2025 · 0 comments
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@cbornet
Copy link
Collaborator

cbornet commented Jan 31, 2025

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

N/A

Error Message and Stack Trace (if applicable)

No response

Description

aconfig_with_context may do blocking calls through the path:
aconfig_with_context -> _config_with_context -> step.config_specs -> RunnableLambda.config_specs -> RunnableLambda.deps -> get_function_nonlocals -> inspect.getsource -> inspect.getsourcelines -> inspect.findsource -> linecache.getlines -> linecache.updatecache -> IO.readlines

Since #29200 the impact is minimized. There's also a LRU cache on get_function_nonlocals and linecache does a cache of the source files as it name implies (but inspect.findsource does blocking os.stat calls to see if the linecache needs to be refreshed).
But still, there may be some improvement to do in aconfig_with_context to make it fully async.
It could be:

  • call asyncio.await(getattr, step, "config_specs")
  • or introduce an async Runnable.aconfig_specs method with a default implementation returning config_specs and override in RunnableLambda
  • or something else ?

This issue was discovered by BlockBuster: see #29043

cc @eyurtsev

System Info

N/A

@dosubot dosubot bot added the 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature label Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
Development

No branches or pull requests

1 participant