Skip to content

Add cancellation support to session::tokio functions#100

Merged
fjarri merged 1 commit intoentropyxyz:masterfrom
fjarri:cancellation
May 21, 2025
Merged

Add cancellation support to session::tokio functions#100
fjarri merged 1 commit intoentropyxyz:masterfrom
fjarri:cancellation

Conversation

@fjarri
Copy link
Copy Markdown
Contributor

@fjarri fjarri commented Apr 30, 2025

This should allow users to impose an external timeout (or to cancel the session loop manually, e.g. on keyboard interrupt).

Also fixed some error processing lapses in par_run_session() where closing of the incoming message channel (or internal channels) was silently ignored.

The timeout support (#12) is still under consideration. The cancellation takes care of the global timeout, or any other cases where the execution needs to be terminated gracefully, but we may still need some partial cutoff times for specific rounds (not clear at this point what the API would be).

@fjarri fjarri self-assigned this Apr 30, 2025
@fjarri fjarri marked this pull request as ready for review April 30, 2025 19:02
@fjarri fjarri requested a review from dvdplm April 30, 2025 19:02
@fjarri
Copy link
Copy Markdown
Contributor Author

fjarri commented Apr 30, 2025

@peg FYI

@coveralls
Copy link
Copy Markdown

coveralls commented Apr 30, 2025

Pull Request Test Coverage Report for Build 14842568648

Details

  • 37 of 44 (84.09%) changed or added relevant lines in 2 files are covered.
  • 12 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.4%) to 72.26%

Changes Missing Coverage Covered Lines Changed/Added Lines %
manul/src/session/tokio.rs 33 40 82.5%
Files with Coverage Reduction New Missed Lines %
manul/src/session/tokio.rs 12 82.97%
Totals Coverage Status
Change from base Build 14842544562: -0.4%
Covered Lines: 2149
Relevant Lines: 2974

💛 - Coveralls

Copy link
Copy Markdown
Contributor

@dvdplm dvdplm left a comment

Choose a reason for hiding this comment

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

I am no expert on tokio but afaik using cancellation tokens like this is idiomatic and the code looks good to me.

As for the question I need to research it a bit more; I honestly don't know what the idiomatic pattern is for deadlines/timeouts. It sounds plausible that cancellation tokens are part of the right answer, but it also seems like there'd a higher level API that we should be using?

@fjarri fjarri merged commit e4412d4 into entropyxyz:master May 21, 2025
8 checks passed
@fjarri fjarri deleted the cancellation branch May 21, 2025 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants