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.
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
Issue 355: ProcessHandler configurable executor timeout #356
Issue 355: ProcessHandler configurable executor timeout #356
Changes from 1 commit
0d4817e
ba0d06b
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
waitForExecutorToStop
must be invoked, otherwise ProcessHandler exists immediately.Check for zero timeout should be done in that method.
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.
EDIT: This reply was written when I had misunderstood your intention for
executorTimeoutMillis == 0
I thought 0 would mean "do not wait at all", but now I think you intended 0 to mean "wait forever".
I still think that this comment is technically correct - there is a small (mostly harmless) edge-case bug.
But to understand the reasoning you will have to imagine that 0ms timeout means 0ms timeout ie "don't wait at all".
Let's discuss the implementation of
waitForExecutorToStop()
.First of all I think that this line
has an edge-case bug.
It should actually use
>=
.Think about the case where
timeoutMillis
== 0:System.currentTimeMillis() - waitStarted
will almost certainly be 0Thread.sleep(100)
In a practical sense, this was not important when we had a constant EXECUTOR_TIMEOUT_MILLIS, and it is not important if we short-circuit for the
timeoutMillis==0
case.But given that we are discussing calling
waitForExecutorToStop()
for the zero case, I thought I should mention it.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.
Second of all I wonder why you have a
do ... while
loop instead of awhile
loop.The
do ... while
deals with the case where the executor has already stopped by the time we runwaitForExecutorToStop()
.In this case, why do we want to force a
Thread.sleep(100)
?Why would we want to log "Executor hasn't yet stopped..." when that is not true?
The log is only at TRACE level, so the practical outcome is pretty harmless.
Further it is perhaps very unlikely to hit this case ... but it seems to me that a
while
loop would be the correct implementation - am I misunderstanding something?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 was confusing me for a long time ... until I realised ... I think I misunderstood your previous request:
What you meant was "a zero value means wait indefinitely".
I thought you meant "a zero value means don't wait at all".
As a general rule in configuration values, I prefer to let zero mean zero - and then use -1, or "any negative value" to mean a special case like "disable the timeout".
The bonus with "any negative value" is that you don't need to check for valid values - all values have some meaning.
However, in this particular case, would an actual
0ms
timeout ever be a useful setting?Perhaps here the "0" as a special value makes sense ...
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.
Even ffmpeg itself uses
-threads 0
as an option to use all threads available.To be honest, I don't care. It's highly unlikely that ffmpeg will complete in 100ms or less.
I think it can be like
if (timeoutMillis> 0 && System.currentTimeMillis() - waitStarted > timeoutMillis) {