Skip to content

fix(watcher): bound WatchedField change queue to prevent unbounded memory growth - #110

Merged
zeevdr merged 1 commit into
mainfrom
fix/py100-bound-watchedfield-queue
May 25, 2026
Merged

zeevdr merged 1 commit into
mainfrom
fix/py100-bound-watchedfield-queue

Conversation

@zeevdr

@zeevdr zeevdr commented May 25, 2026

Copy link
Copy Markdown
Member

Summary

  • Closes Bound WatchedField change queue to prevent memory growth #100
  • Add max_queue_size parameter (default 1024) to WatchedField and AsyncWatchedField
  • Drop-oldest strategy: when the queue is full, the oldest entry is evicted and dropped_changes is incremented
  • Log a WARNING on each drop (path, max size, running total)
  • ConfigWatcher.field() and AsyncConfigWatcher.field() accept and forward max_queue_size
  • Matches the TypeScript SDK's queue overflow semantics (DEFAULT_QUEUE_SIZE = 1024, drop-oldest)

Test plan

  • dropped_changes starts at 0 and increments once per overflow
  • Queue never exceeds max_queue_size entries
  • Oldest entries are evicted (newest N survive)
  • Warning logged with field path on each drop
  • max_queue_size constructor arg sets the bound; default is 1024
  • changes() / async for iterator yields only surviving entries after overflow
  • Existing watcher tests pass unchanged

🤖 Generated with Claude Code

…mory growth

Add max_queue_size parameter (default 1024) to WatchedField and
AsyncWatchedField. When the queue is full, the oldest entry is dropped
(drop-oldest strategy) and dropped_changes is incremented. A warning is
logged on each drop. Matches the TypeScript SDK's queue overflow semantics.

Closes #100

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@codecov

codecov Bot commented May 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.00000% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
sdk/src/opendecree/async_watcher.py 92.00% 2 Missing ⚠️
sdk/src/opendecree/watcher.py 96.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@zeevdr
zeevdr merged commit 65de401 into main May 25, 2026
15 checks passed
@zeevdr
zeevdr deleted the fix/py100-bound-watchedfield-queue branch May 25, 2026 20:20
@github-project-automation github-project-automation Bot moved this from Todo to Done in OpenDecree May 25, 2026
@Mirochill Mirochill mentioned this pull request May 26, 2026
6 of 9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Bound WatchedField change queue to prevent memory growth

1 participant