Silence httpcore/httpx/openai loggers to stop event-loop wedge (v0.99.94)

Under --debug, httpcore emits a connection-close DEBUG trace from the OpenAI
client's __del__ finalizer. Under load, that finalizer runs during a GC pause
that can land mid-flush of aisbf.log, re-entering the same RotatingFileHandler
and raising "RuntimeError: reentrant call inside BufferedWriter". This cascades
and blocks the asyncio event loop: uvicorn keeps the port bound (LISTEN, Recv-Q
backing up) but stops accepting connections, so the web interface hangs.

Pin httpcore/httpx/openai to WARNING regardless of debug mode so a finalizer can
never emit a DEBUG/INFO record into the reentrant path. Also removes a large
share of the log volume. aisbf's own --debug logging is unaffected.

Verified in production: 0 reentrant errors and 0 httpcore DEBUG lines under live
load after restart; server stable and responsive.
Co-Authored-By: 's avatarClaude Opus 4.8 (1M context) <noreply@anthropic.com>
parent 39c0481a
...@@ -55,7 +55,7 @@ from .auth.qwen import QwenOAuth2 ...@@ -55,7 +55,7 @@ from .auth.qwen import QwenOAuth2
from .handlers import RequestHandler, RotationHandler, AutoselectHandler from .handlers import RequestHandler, RotationHandler, AutoselectHandler
from .utils import count_messages_tokens, split_messages_into_chunks, get_max_request_tokens_for_model, get_max_completion_tokens_for_model from .utils import count_messages_tokens, split_messages_into_chunks, get_max_request_tokens_for_model, get_max_completion_tokens_for_model
__version__ = "0.99.93" __version__ = "0.99.94"
__all__ = [ __all__ = [
# Config # Config
"config", "config",
......
...@@ -137,6 +137,25 @@ def setup_logging(): ...@@ -137,6 +137,25 @@ def setup_logging():
): ):
logging.getLogger(noisy_logger).setLevel(logging.INFO if AISBF_DEBUG else logging.WARNING) logging.getLogger(noisy_logger).setLevel(logging.INFO if AISBF_DEBUG else logging.WARNING)
# HTTP client libraries emit extremely high-volume DEBUG traces (every
# connection open/close/send/receive). Beyond the noise, httpcore logs a
# connection-close trace from the OpenAI client's __del__ finalizer; under
# load that finalizer runs during a garbage-collection pause that can land
# mid-flush of aisbf.log, re-entering the same file handler and raising
# "RuntimeError: reentrant call inside BufferedWriter" — which cascades and
# blocks the asyncio event loop (the server keeps the port bound but stops
# accepting connections). Pin these to WARNING regardless of debug mode so a
# finalizer can never emit a DEBUG/INFO record into the reentrant path.
for http_logger in (
'httpcore',
'httpcore.connection',
'httpcore.http11',
'httpcore.http2',
'httpx',
'openai',
):
logging.getLogger(http_logger).setLevel(logging.WARNING)
bpf = BrokenPipeFilter() bpf = BrokenPipeFilter()
for h in (file_handler, error_handler, console_handler): for h in (file_handler, error_handler, console_handler):
h.addFilter(bpf) h.addFilter(bpf)
......
...@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" ...@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "aisbf" name = "aisbf"
version = "0.99.93" version = "0.99.94"
description = "AISBF - AI Service Broker Framework || AI Should Be Free - A modular proxy server for managing multiple AI provider integrations" description = "AISBF - AI Service Broker Framework || AI Should Be Free - A modular proxy server for managing multiple AI provider integrations"
readme = "README.md" readme = "README.md"
license = "GPL-3.0-or-later" license = "GPL-3.0-or-later"
......
...@@ -106,7 +106,7 @@ class InstallCommand(_install): ...@@ -106,7 +106,7 @@ class InstallCommand(_install):
setup( setup(
name="aisbf", name="aisbf",
version="0.99.93", version="0.99.94",
author="AISBF Contributors", author="AISBF Contributors",
author_email="stefy@nexlab.net", author_email="stefy@nexlab.net",
description="AISBF - AI Service Broker Framework || AI Should Be Free - A modular proxy server for managing multiple AI provider integrations", description="AISBF - AI Service Broker Framework || AI Should Be Free - A modular proxy server for managing multiple AI provider integrations",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment