Skip to content

python: bound the SSE event queue (backpressure) #74

Done

Description

@akosidencio

The Python SDK's event loop hands parsed stream events to the client through an unbounded queue (sdks/python/python/checkgate/_loop.py). Line and event sizes are bounded (16 MiB), but the number of queued events is not. If events arrive faster than the client applies them, memory use can grow without a limit. Reaching that state needs a misbehaving server or network path. This was found in the 0.2.0 review, rated low, and accepted for 0.2.0.

Acceptance criteria

  • A per-stream in-flight budget (bytes and/or events) with a documented default; it is configurable on CheckgateClient.
  • When the budget is exceeded, the client drops the stream and reconnects, resuming from its last applied revision. No delta is applied out of order, and get_health() reports the event.
  • Test: a stub server that streams large events faster than a deliberately slow consumer keeps the client's queued bytes at or below the budget. Peak RSS growth stays within the budget plus 32 MiB.
  • The shared fault-injection suite (sdks/conformance) and sdks/python/tests pass unchanged.
  • sdks/python/README.md documents the option.

Activity

  1. added this to the v0.2.1 milestone on Nov 22, 2026
  2. added
    enhancement
    on Nov 22, 2026
  3. added a commit that references this issue on Nov 30, 2026
  4. akosidencio commented on Nov 30, 2026

    @akosidencio
    MemberAuthor

    Fixed in 0.2.1 by #96 (merged to dev; part of the 0.2.1 release).

    Verification: Python SDK tests in CI (3.11, 3.13) and the shared SSE fault-injection suite; a stream flood test kept client RSS under 48 MiB with the default max_stream_backlog_bytes.

    Details are in the 0.2.1 changelog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions