-
Notifications
You must be signed in to change notification settings - Fork 247
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
Abort prometheus worker on farmer exit. #2104
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will not have the desired effect. It will work on Ctrl+C, but the idea was that it should be stopped on drop. Future returned by fn farm
doesn't have to complete, it could hypothetically be simply dropped any time.
Do you mean something like |
Yes, |
Well, not really. |
Did you comment on |
I see, we don't have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So there is a wrapper now that is sending abort
to the task on drop, which is correct.
The part with Future
would have also worked under different circumstances, but in this case it will not because Drop
means no one will ever be able to poll the future again, so effectively the wrapper can be simplified to just self.task.abort()
in Drop
and it will behave exactly the same.
Since you trigger internal abort already is, all you need to do is to additionaly wrap the task in AsyncJoinOnDrop
to ensure that it is both aborted on drop and Drop::drop
only exits once background task has actually finished.
And I'd call it in more generic way like AsyncAbortOnDrop
you suggested before.
# Conflicts: # crates/subspace-farmer/src/bin/subspace-farmer/commands/farm.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since AsyncJoinOnDrop
wraps JoinHandle
and not arbitrary future, we don't actually need Fuse
, we can call JoinHandle::is_finished
instead of is_terminated
, in which case we can update AsyncJoinOnDrop::new()
with additional argument abort_on_drop: bool
and just call abort
beore task::block_in_place
. It'll be a simpler abstraction here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fairly clean, I'll squash-merge once CI passes
This PR adds abortion for an optional Prometheus task serving farmer's metrics on the application exit.
Code contributor checklist: