fix: Stop using api_core default timeouts in publish since they are broken #1326
+19
−2
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.
Change in behavior
60s initial deadline for RPCs reduced to 5s. Other timeout parameters changed changed:
Change
Only non-test / non sample(i.e functional) usage found for
PublisherOptions.timeout
is here:python-pubsub/google/cloud/pubsub_v1/publisher/client.py
Lines 440 to 441 in f648f65
This change in usage is intended.
Call stack:
python-pubsub/google/cloud/pubsub_v1/publisher/client.py
Line 299 in f648f65
invokes one of the sequencers(ordered or unordered)
python-pubsub/google/cloud/pubsub_v1/publisher/client.py
Lines 477 to 479 in f648f65
which then create a batch with this timeout
python-pubsub/google/cloud/pubsub_v1/publisher/_sequencer/ordered_sequencer.py
Lines 255 to 263 in f648f65
which uses it when committing the batch / publishing the messages:
python-pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py
Lines 323 to 328 in f648f65
and invokes gapic_publish:
python-pubsub/google/cloud/pubsub_v1/publisher/client.py
Lines 289 to 291 in f648f65
which then uses it in the RPC call:
python-pubsub/google/pubsub_v1/services/publisher/client.py
Lines 1067 to 1072 in f648f65
that is obtained by wrapping the transport base publish call:
python-pubsub/google/pubsub_v1/services/publisher/client.py
Line 1055 in f648f65
The wrapper uses the timeout when invoking the GapicCallable:
https://github.com/googleapis/python-api-core/blob/b1fae31c8c71ed65ad22a415dab2b54720c3d4ba/google/api_core/gapic_v1/method.py#L245-L252
which currently overrides float and int timeouts to use TimeToDeadlineTimeout:
https://github.com/googleapis/python-api-core/blob/b1fae31c8c71ed65ad22a415dab2b54720c3d4ba/google/api_core/gapic_v1/method.py#L112-L113
which is incorrect(why its incorrect is mentioned in the attached bug)
Fixes #1325 🦕