2d87bd88a2
LangGraph._setup_node_stream_subscriptions() was discarding the Disposable returned by observable.subscribe(), making it impossible for stop() to clean up active subscriptions. This caused resource leaks and prevented garbage collection of LangGraph instances (the on_error closure captured self.logger). Changes: - Add self._subscriptions: list[Any] = [] to LangGraph.__init__ - Store each Disposable returned by observable.subscribe() in _subscriptions - Dispose all stored subscriptions in stop() using contextlib.suppress(Exception) - Clear _subscriptions list after disposal - Add BDD feature and step definitions for TDD issue #10398 ISSUES CLOSED: #10398
30 lines
1.4 KiB
Gherkin
30 lines
1.4 KiB
Gherkin
@tdd_issue @tdd_issue_10398
|
|
Feature: TDD Issue #10398 — LangGraph._setup_node_stream_subscriptions stores and disposes RxPy Disposables
|
|
As a CleverAgents developer
|
|
I want LangGraph to store the Disposable returned by observable.subscribe()
|
|
So that stop() can dispose all subscriptions and prevent resource leaks
|
|
|
|
Background:
|
|
Given the LangGraph module is available
|
|
|
|
Scenario: LangGraph initialises an empty subscriptions list
|
|
When I construct a LangGraph with default configuration
|
|
Then the graph should have an empty _subscriptions list
|
|
|
|
Scenario: _setup_node_stream_subscriptions stores Disposables
|
|
Given a LangGraph instance with one worker node
|
|
When I inspect the subscriptions after construction
|
|
Then the _subscriptions list should contain at least one entry per node
|
|
|
|
Scenario: stop() disposes all stored subscriptions
|
|
Given a LangGraph instance with tracked disposable subscriptions
|
|
When I call stop() on the graph
|
|
Then every tracked disposable should have been disposed
|
|
And the _subscriptions list should be empty after stop
|
|
|
|
Scenario: stop() clears subscriptions even when dispose raises
|
|
Given a LangGraph instance with a subscription that raises on dispose
|
|
When I call stop() on the graph with a failing disposable
|
|
Then stop() should complete without raising an exception
|
|
And the _subscriptions list should be empty after the failing stop
|