fix: bound inflight report threads with semaphore

Add _MAX_INFLIGHT semaphore (cap=10) so thread spawning is bounded
during mass failures. If 10 reports are already in flight, new ones
are silently dropped instead of exhausting OS thread limits.
This commit is contained in:
Vikas Sharma 2026-07-16 21:33:55 +05:30
parent 557c87f4ce
commit 9febf728df

View file

@ -23,6 +23,7 @@ from litellm.llms.custom_httpx.http_handler import _get_httpx_client
_REPORT_URL = "https://tickerr.ai/api/v1/report"
_UA = "litellm-tickerr/1.0"
_MAX_INFLIGHT = threading.Semaphore(10)
class TickerrLogger(CustomLogger):
@ -124,6 +125,8 @@ class TickerrLogger(CustomLogger):
}
def _send() -> None:
if not _MAX_INFLIGHT.acquire(blocking=False):
return
try:
client = _get_httpx_client()
client.post(
@ -134,5 +137,7 @@ class TickerrLogger(CustomLogger):
)
except Exception:
pass
finally:
_MAX_INFLIGHT.release()
threading.Thread(target=_send, daemon=True).start()