Skip to content

[Python SDK] Mixing threads and async code #620

Description

@pocesar

Describe the bug

The code contains a dangerous mix of threading.Lock, background threads, asyncio counterparts, requests blocking calls, dynamic lock creation and no timeout on most acquired locks.

Since most of the time you'll be using FastAPI + decorators for skill / reasoner, it'll always be a single event loop that can be blocked by blocking or nested calls.

It's very hard to debug when this happens, and some runs can stay stuck in time for hours. I recommend adding mypy and ruff for strict checks of async / blocking code

Steps to reproduce

  1. Go to '...'
  2. Run '...'
  3. See error

Expected behavior

Screenshots / Logs

Environment

  • Control plane version: 1.88
  • SDK version (if applicable): 1.85
  • Deployment environment (local, docker, kubernetes, etc.): Local, docker, kubernetes

Additional context

Metadata

Metadata

Assignees

Labels

area:sdkCross-SDK (Python + Go + TS) parity workbugSomething isn't workingsdk:pythonPython SDK related

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions