Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ZhangHanDong
Copy link

@ZhangHanDong ZhangHanDong commented Apr 30, 2025

Fixed #500

Currently, source (input-less) Dora nodes close their event stream immediately after startup, making them unable to receive an ‎⁠Event::Stop⁠ signal (such as from Ctrl+C or ‎⁠dora stop⁠). This prevents graceful shutdown.

Solution:

A new optional node configuration field, ‎⁠wait_for_stop: bool⁠, is introduced to control event stream behavior after all inputs are closed:

  • ‎⁠wait_for_stop: false⁠: The event stream ends when all inputs are closed (default for nodes with inputs; unchanged).
  • wait_for_stop: true⁠: The event stream remains open until an explicit ‎⁠Event::Stop⁠ signal is received (default for source nodes with no inputs).

Users can override the default by setting this option explicitly in the dataflow YAML file.

Key Changes:

  1. dora-message⁠:
    • Added ‎⁠wait_for_stop: Option<bool>⁠ to ‎⁠descriptor::Node⁠ for YAML parsing.
    • Added ‎⁠wait_for_stop: bool⁠ to ‎⁠descriptor::ResolvedNode⁠ to store the resolved value.
  2. dora-core⁠:
    • Updated ‎⁠descriptor::resolve_aliases_and_set_defaults⁠ to compute the final ‎⁠ResolvedNode.wait_for_stop⁠ value based on inputs and YAML settings. Fixed related ownership bug.
  3. cora-daemon⁠:
    • Updated node spawning (‎⁠spawn::spawn_node⁠) to pass ‎⁠ResolvedNode.wait_for_stop⁠ to the node communication listener (‎⁠node_communication::spawn_listener_loop⁠ and implementation).
    • Modified listener logic (‎⁠node_communication::Listener⁠) to check the ‎⁠wait_for_stop⁠ flag when deciding whether to send ‎⁠AllInputsClosed⁠ or end the event stream. The event stream now only ends naturally if ‎⁠wait_for_stop⁠ is ‎⁠false⁠.
    • Ensured all nodes’ event streams can be stopped by ‎⁠Event::Stop⁠, regardless of ‎⁠wait_for_stop⁠.
  4. Updated ‎⁠dora-schema.json⁠ to include the ‎⁠wait_for_stop⁠ field.

Impact:

  • Source nodes now stay running by default and can respond to stop signals as expected.
  • Users who want source nodes to exit immediately can set ‎⁠wait_for_stop: false⁠.
  • Nodes with inputs retain their default (exit when inputs close), but can be set to wait for stop if desired.
  • Fixed a bug in config resolution due to ownership issues.

Todos:

  • Update core documentation (‎⁠libraries/core/README.md⁠) to explain the new config and defaults.
  • Update Node API docs (Rust, Python, C, C++) about event stream lifecycle.

Todo Test:

  • Source node default (waits for Stop).
  • Source node with ‎⁠wait_for_stop: false⁠ (exits immediately).
  • Node with inputs default (ends when inputs close).
  • Node with inputs and ‎⁠wait_for_stop: true⁠ (waits for Stop).
  • Stopping with Ctrl+C and ‎⁠dora stop⁠.

Copy link
Collaborator

@phil-opp phil-opp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me overall, thanks a lot! There are some CI failures that are probably caused by the handling of runtime nodes/operators. See my inline comment.

@phil-opp phil-opp added the waiting-for-author The pull request requires adjustments by the PR author. label May 21, 2025
@ZhangHanDong ZhangHanDong marked this pull request as ready for review May 28, 2025 09:01
@ZhangHanDong ZhangHanDong requested a review from phil-opp May 28, 2025 11:05
Copy link
Collaborator

@phil-opp phil-opp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the adjustments!

@ZhangHanDong ZhangHanDong requested a review from phil-opp June 11, 2025 12:58
@ZhangHanDong
Copy link
Author

@phil-opp

There is a permission error in CI/ROS2 Bridge Examples.

Invoking "sudo apt-get update"
Error: The process '/usr/bin/sudo' failed with exit code 100

@ZhangHanDong
Copy link
Author

@phil-opp

This CI might have some issues. I didn’t update the code for the past two weeks, but the CI kept running continuously for two weeks without showing any error messages.

Screenshot 2025-06-11 at 19 36 43
Screenshot 2025-06-11 at 19 36 58

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

Labels

waiting-for-author The pull request requires adjustments by the PR author.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nodes with no inputs has empty events stream

2 participants