-
Notifications
You must be signed in to change notification settings - Fork 214
Closed
Labels
api: pubsubIssues related to the googleapis/python-pubsub API.Issues related to the googleapis/python-pubsub API.samplesIssues that are directly related to samples.Issues that are directly related to samples.type: docsImprovement to the documentation for an API.Improvement to the documentation for an API.
Description
The streaming pull future's cancel() is non-blocking. If subscriber client is used as a context manager that closes the underlying channel, but the client does not block when shutting down the stream (e.g. it just calls future.cancel()), the channel can be closed before the subscriber sends the last requests to the server (e.g. auto NACK of any remaining messages).
The block below is common in the existing samples:
with subscriber:
try:
# When `timeout` is not set, result() will block indefinitely,
# unless an exception occurs first.
streaming_pull_future.result(timeout=timeout)
except TimeoutError:
streaming_pull_future.cancel()The samples should demonstrate how to block before leaving the with block, but they currently do no, and users have observed errors on shutdown (example). This should be fixed.
Metadata
Metadata
Assignees
Labels
api: pubsubIssues related to the googleapis/python-pubsub API.Issues related to the googleapis/python-pubsub API.samplesIssues that are directly related to samples.Issues that are directly related to samples.type: docsImprovement to the documentation for an API.Improvement to the documentation for an API.