Add exception capture for CreateLogStream to avoid flush get stuck #192
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.
Add exception capture for CreateLogStream, to avoid flush stuck when CreateLogStream throttle.
This PR is to address some situation mentioned in issue #132 . When CreateLogStream error out in batch mode (
use_queues==True
), e.g. throttle on this action, theflush()
andclose()
could be stuck atq.join()
. Because the exception raised during CreateLogStream stopped the log delivering thread, then the queue will never get cleared, then the main thread get stuck.After adding the exception capture, the log delivering thread would be able to proceed to retry up on CreateLogStream throttle.
This PR only covers one of the causes of stuck I am experiencing. It does not introduce breaking changes, so can be published as patch version.
There might be more reasons causing stuck in
flush()
. It would be better to add a timeout inflush()
. However, it will change the interface: adding a timeout threshold as a new argument in the class init and/orflush()
. I will raise a separate PR for it.