fix: Handle TransportError Exceptions thrown from gapic_publish #1318
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.
Current behavior:
If
TransportError
is thrown bygoogle.auth
library:https://github.com/googleapis/google-auth-library-python/blob/c3ea09fd8b9ee8f094263fdc809c59d9dfaa3124/google/auth/compute_engine/_metadata.py#L187-L189
when doing a
_gapic_publish
:python-pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py
Lines 322 to 327 in f79d35a
Then,
python-pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py
Line 345 in f79d35a
python-pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py
Line 348 in f79d35a
python-pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py
Lines 364 to 369 in f79d35a
gapic_publish
was occuring dies without setting the correct batch state / future exceptions:python-pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py
Lines 237 to 239 in f79d35a
python-pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py
Line 288 in f79d35a
python-pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py
Lines 449 to 450 in f79d35a
python-pubsub/google/cloud/pubsub_v1/publisher/_sequencer/ordered_sequencer.py
Lines 323 to 326 in f79d35a
Behavior expected with change
TransportError
duringgapic_publish
will be caught in addition to the existingGoogleAPIError
python-pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py
Line 345 in f79d35a
GoogleAPIError
is caught duringgapic_publish
would also now apply toTransportError
, i.e:ERROR
, future exceptions will be set:python-pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py
Lines 345 to 371 in f79d35a
AssertionError
:python-pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py
Lines 444 to 447 in f79d35a
which will be bubbled up through the Ordered / Unordered Sequenceer's
publish
method:python-pubsub/google/cloud/pubsub_v1/publisher/_sequencer/ordered_sequencer.py
Lines 321 to 328 in f79d35a
to the Publisher client's
publish
method:python-pubsub/google/cloud/pubsub_v1/publisher/client.py
Lines 477 to 495 in f79d35a
which would bubble the exception back to the user
Additional details can be found here: #1173 (comment)
Fixes #1173 🦕