Skip to content

core: task not awaited in create_base_retry_decorator #30791

Open
@cbornet

Description

@cbornet

Checked other resources

  • I added a very descriptive title to this issue.
  • 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).
  • I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Example Code

Increate_base_retry_decorator, a task is created but without reference and is never awaited.

Description

This is dangerous as stated in RUF006:

Per the asyncio documentation, the event loop only retains a weak reference to tasks. If the task returned by asyncio.create_task and asyncio.ensure_future is not stored in a variable, or a collection, or otherwise referenced, it may be garbage collected at any time. This can lead to unexpected and inconsistent behavior, as your tasks may or may not run to completion.

This was detected by #29353

Metadata

Metadata

Assignees

Labels

investigateFlagged for investigation.Ɑ: coreRelated to langchain-core🤖:bugRelated to a bug, vulnerability, unexpected error with an existing feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions