-
Notifications
You must be signed in to change notification settings - Fork 6
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
Task abort and other stop fix-ups #253
Conversation
|
Also catch errors in the stop function. Document the signatures for process/task start/stop functions.
By default, the code will expect the stop function to run the same way as the start function. Some existing agents have non-blocking start functions, but the stoppers are not written with inlineCallbacks; the current code will notice this and print a warning message.
They should run in the reactor now.
This functions the same way as Process "stop", except that it is entirely optional and should normally cause the operation to exit with error.
In addition to errback there is now also a callback to print something to the log on success. The errback had a typo so it probably never worked in the past.
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 great! I caught a couple of small things, but otherwise looks good.
I would like to incorporate this into the Agent writing guide so that there's documentation for how to implement a task aborter. I'm thinking maybe the barebones agent's print task could be renamed "repeat" or something, having it repeat a string X number of times, waiting a second in between, and allowing us the ability to abort. Just trying to keep the task simple...
What about for more complicated, longer running tasks? Should the Agent just occasionally check session.status
and return if it sees it's no longer "running"?
Alright, short new section in the task part of the Agent writing guide introduced in d36c161. One thing that occurred to me is that maybe we should have some indication of which tasks can be aborted in the docstrings for tasks that do have an aborter implemented? Any ideas here? |
Thanks for the fixes and docs.
Ya, perhaps:?
Also it may be worth saying, in the section that you added, that stop functions in processes are basically the same thing. Also please mention that when a Task is aborted it should normally return with error. |
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.
Great, thanks for the suggestions. I pushed a small update. Will go ahead with the merge when the checks pass. Then prep a new ocs release.
Description
Motivation and Context
Task abort has always been a planned part of the API, with similar behavior to Process stop. As we transition to more realistic and automated operation, long-running Tasks need to have smart abort capabilities (we can't just cycle the Agent whenever a Task needs to be interrupted).
Resolves #214.
How Has This Been Tested?
I tested this using the FakeDataAgent and HostManager, through ocs-web. I also confirmed the OCSClient interface passes abort requests successfully.
Types of changes
The potentially breaking change here is that stopper functions (for Processes) will now be run in the same threading pattern (reactor or worker thread) as the starter function, unless the user explicitly requests the other pattern when registering the Process. Previously, the default was to always launch the stopper in a worker thread.
So the new default could affect any Process that is currently registered with blocking=False. However (a) such Processes are rare and (b) there's a bit of code that will catch the case that a stopper function doesn't return a Deferred.
Checklist:
develop
branch.