Check stream status and stop running streams before operations #231
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Just a draft for now. There are a couple of implementation things to maybe work out, and I need to write tests.
This PR adds a check when running an operation for streams that are still running. The check occurs after the operation will have failed due to the task not being able to grab the ocs
TimeoutLock
within the agent because thestream
process was left running, and before we drop the client due to this error.We check if a stream is still running, and if it is, try to stop it. If we can stop it, great, it's now stopped and we drop that client. It'll get picked back up in the schedule at the next
initialize()
. If we can't stop it (the.wait()
times out after 2 minutes), then we raise an exception, crashing the schedule.The one sticking point to discuss is what to do on
ClientControlError
, which is likely when there's a network issue. This was the culprit in recent streams being left on, as described in #229. As written right now, if we can't check the status ofstream
, we crash the schedule. This, along with other similar errors when trying to stop/wait for the streams, do the same. This likely leaves the streams running if they were running already. The only indication of this is the "Streams may still be running" in the error message.I'll aim to discuss this last point in the #229 issue. Just wanted to get the example code for this solution up in draft form.