Files
cleveragents-core/features/tdd_reactive_event_bus_close.feature
HAL9000 3459f821c5 fix(events): add close() method to ReactiveEventBus to complete RxPY subject
Add _closed flag and close() method to ReactiveEventBus to complete the
RxPY Subject, preventing subscriber resource leaks. close() is idempotent
and raises RuntimeError when called on a closed bus.

Also adds:
- emit() guard against post-close calls (RuntimeError)
- __enter__/__exit__ context manager protocol for automatic cleanup
- BDD scenarios in event_bus.feature and TDD tests in
  tdd_reactive_event_bus_close.feature

ISSUES CLOSED: #10378
2026-05-13 12:24:33 +00:00

40 lines
1.8 KiB
Gherkin

@tdd_issue @tdd_issue_10377
Feature: TDD Issue #10377 — ReactiveEventBus missing close() method causes RxPY subscriber resource leaks
As a developer using ReactiveEventBus with RxPY operators
I want the bus to provide a close() method that completes the RxPY Subject
So that buffering and aggregation operators can finalize their state without leaking resources
This test suite captures bug #10378 / TDD issue #10377.
The tests verify that ReactiveEventBus.close() completes the RxPY stream,
that emit() raises RuntimeError after close(), and that the bus supports
the context manager protocol for automatic cleanup.
See CONTRIBUTING.md > Bug Fix Workflow > TDD Issue Test Tags.
@tdd_issue @tdd_issue_10377
Scenario: ReactiveEventBus.close() completes the RxPY stream
Given a ReactiveEventBus instance for close testing
And a subscriber collecting completion signal from bus stream
When bus.close() is called
Then the subscriber should have received the on_completed signal
@tdd_issue @tdd_issue_10377
Scenario: ReactiveEventBus.close() prevents further emit() calls
Given a ReactiveEventBus instance for close testing
When bus.close() is called
And an event is emitted after close
Then a RuntimeError should be raised
@tdd_issue @tdd_issue_10377
Scenario: ReactiveEventBus implements context manager protocol
Given a ReactiveEventBus instance used as a context manager
When the context manager exits
Then bus.close() should have been called automatically
And the RxPY stream should be completed
@tdd_issue @tdd_issue_10377
Scenario: ReactiveEventBus.close() is idempotent
Given a ReactiveEventBus instance for close testing
When bus.close() is called twice
Then no exception should be raised on the second close call