Blocking the event loop since 3.x ?

Offen
#3,777 12 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@nivas4506 arbeitet bereits daran.

Seit 07.9.2026.

  • #3815 von @nivas4506 — offen

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
30/100
Issue-Typ
Bug
Klarheit
Muss geklärt werden
Aktivitätsstatus
Aktiv
Tech-Stack
python, redis
Bereich
backend, performance

Rechercherichtung

Beginnen Sie damit, das Upgrade von Version 2.54 auf 3.6.0 in einem Python-asyncio-Dienst mit chat completions oder structured outputs zu reproduzieren, während Sie CPU und die Reaktionsfähigkeit der Ereignisschleife überwachen. Vergleichen Sie den standardmäßigen httpx-Client mit dem httpx aiohttp-Client und überprüfen Sie, ob Redis, aiokafka oder andere asynchrone Vorgänge nach mehreren Stunden weiterhin mit einem Timeout fehlschlagen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug
Confirm this is an issue with the Python library and not an underlying OpenAI API
  • This is an issue with the Python library
Describe the bug

We run a service using a standard asyncio event loop, running various async code like aiokafka, redis (async) or aiohttp. After upgrading to 3.x version, we notice after a while symptoms that the event loop is blocked:

  • timeout accessing redis
  • timeout with the aiokafka coordinator/heartbeat co-routine

We tried using the default httpx2 client or httpx2 aiohttp client, but it doesn't solve the issue. Reverting to 2.54 solves the issue

Sorry to be so vague, we have nothing in our logs that could give a pointer to a more precise section of the code. We do use chat completion APIs, and structured output with Pydantic

To Reproduce
  1. Update to 3.x
  2. Wait few hours, the CPU usage is raising, symptom of blocked event loop appears
Code snippets

OS

Linux x86

Python version

Python v3.12.3

Library version

OpenAI v3.6.0

Vorherrschende Sprache
Python
Sterne
32.2k
Forks
5.8k
Ø Merge
12 Std. 29 Min.
Gemergte PRs (30 T.)
112

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus openai/openai-python

Alle Issues in openai/openai-python

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.