pipeline destroy do not rely on stop propagate signal - #161
Merged
b3by merged 12 commits intoApr 17, 2026
Merged
Conversation
- Implement "draining" state to prevent message loss during shutdown. - Use threading.Condition to ensure all pending updates complete before joining. - Replace sentinel None values in queues with timeouts to prevent hung threads. - Fix potential deadlock by checking current_thread during join. - Add 'Dumper' test sink and updated pipeline configurations for validation.
…-on-stop-propagate-signal
- add e2e test to check draining mode - add e2e test to check immediate stop - add unit test to check message overflow resilience - add unit test to check deadlock resilience on real work
GaijinKa
deleted the
hotfix/pipeline-destroy-do-not-rely-on-stop-propagate-signal
branch
April 20, 2026 10:32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR refines the lifecycle management of nodes and pipelines within the Juturna core library. The primary focus is on implementing a robust shutdown mechanism that ensures data integrity by "draining" nodes before they fully stop. By introducing a
join()method and using threading conditions to track pending updates, the system now waits for active tasks to complete before releasing resources.These changes address several race conditions and resource management issues during pipeline termination, specifically targeting the improvements discussed in issue #160.
PR type
Key modifications and changes
_pending_condition(threading.Condition) and a_pending_updatescounter to theNodeclass to track in-flight data processing.join()method inNodeto safely wait for internal threads (source,worker,update) to terminate, ensuring they are not joined by the current thread.synchronisersetter where it incorrectly assigned to the public property name instead of the private_synchroniserattribute._drainingevent to signal when a node is stopping, allowing it to discard new incoming messages while finishing current work.Pipeline.stop()to iterate through nodes layer-by-layer (BFS) and explicitly calljoin()on each node after sending aSTOPsignal.Buffer.getand internal node loops to use timeouts (0.1s) instead of blocking indefinitely, allowing threads to check for stop events more frequently.SUSPENDandRESUMEsignals were not wrapped in aMessageandControlPayloadobjects.DESTROYEDtoPipelineStatusand ensured the pipeline status is updated upon calling thedestroy()method.PipelineManager.stop_pipelineby removing redundant manual status updates, delegating state management to the pipeline itself.Affected components
juturna.components(_buffer.py,_node.py,_pipeline.py,_pipeline_manager.py)Additional context
The transition from blocking
get()calls to timeout-based loops significantly reduces the risk of "zombie" threads remaining active after a pipeline stop command. By tracking_pending_updateswith aConditionvariable, the node now ensures that any call to theupdate()method is fully completed before the thread is joined and resources are released.