Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cancellation tokens in stead of channels for shutting down #136

Merged
merged 2 commits into from
Mar 11, 2024

Conversation

albertotirla
Copy link
Member

this works as expected, minimising the use of channels, especially where they are not needed, when shutting down.
furthermore, based on my previous assessments, the tokens method of shutting down is more responsive, producing an imediate shutdown.

warning!
the last commit, which removed the last channel for shutdown purposes in use in the codebase that I could see, introduced the hanging bug again. I used gdb to trace it to somewhere around the odilia::events::dispatch_wrapper function, for no obvious reason.
Please don't merge this yet, more review is required. The previous commits except the last one are known to work perfectly, so the change seemns small, but apparently it has long ramifications I can't anticipate, and a cursory look at the affected code doesn't reveal anything of importance.
so then, this should probably be solved with tokio-console, which someone with a tiny bit more vision than me should try and use as well, I tryed, but I couldn't make sense of the interface at all.

Copy link

codecov bot commented Mar 8, 2024

Codecov Report

Attention: Patch coverage is 0% with 51 lines in your changes are missing coverage. Please review.

Project coverage is 16.64%. Comparing base (dc84bd9) to head (5873c3d).

Files Patch % Lines
odilia/src/main.rs 0.00% 46 Missing ⚠️
odilia/src/events/mod.rs 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #136      +/-   ##
==========================================
+ Coverage   16.60%   16.64%   +0.04%     
==========================================
  Files          22       22              
  Lines        1650     1646       -4     
==========================================
  Hits          274      274              
+ Misses       1376     1372       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@TTWNO
Copy link
Member

TTWNO commented Mar 9, 2024

LGTM! I can not reproduce your hanging problem. My assumption is that there is still an edge case where hangs happen, but this is a good simplification of the code (especially directly encoding the cancellation event in the type system), and I'd be happy to see this merge, if only to simplify the understanding of the underlying problem :)

@albertotirla
Copy link
Member Author

alright, now I can't reproduce that bug myself either, but there's clearly some kind of issue which presents itself intermittently. More investigation is required, but for now, this needs afew finishing touches and can be merged

@TTWNO
Copy link
Member

TTWNO commented Mar 11, 2024

Want to acknowledge the good call on @albertotirla 's part to recommend using Trackers, and CancellationTokens. This is a marked improvement in Odilia's readability and maintainability.

now, in stead of a channel, the task recieves a cancelation token, monitoring that one. Not much of a change from the previous model, but at least the intent is clearer
untill all tasks gain the ability to use the cancelation token, the sigint signal handler will have to support both options of shutting down

add tokio-utils to workspace dependencies and make tts use cancelation tokens

fix clippy warnings and add cancellation token to the at-spi event processor

add cancellation tokens to another at-spi processor

add cancellation tokens to the input processing handler

add cancellation tokens to the screenreader events processor, the one which handles input events

fix formatting problems reported by check

remove the last use of the shutdown channel from the codebase, the sigint watcher now  only cancels that token

Update ssip-client-async version

Move Receives insated of mutably borrinwg them for the duration of the running of Odilia

Update Cargo.lock

Cargo format

Fix clippy issues

Update cargo lock
this introduces a timeout of hardcoded 500 milliseconds to the future which awaits all tasks to complete.
If, for example, a task is stuck somewhere and doesn't answer to cancelation tokens, we will exit the program forcefully, with an error code and the error will be displayed before exitting.
I believe around 500 milliseconds is enough for all tasks to get unstuck, but this will eventually be changeable within the configuration file.
For now though, the odilia is hanging on exit problem should probably be relatively well fixed with this
@TTWNO TTWNO merged commit b77a72d into main Mar 11, 2024
10 of 11 checks passed
@albertotirla albertotirla deleted the cancelation-tokens branch September 7, 2024 19:49
@TTWNO TTWNO restored the cancelation-tokens branch November 8, 2024 21:53
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.

2 participants