Skip to content

The changed behavior of StreamingPullFuture.cancel() should be documented #419

@plamut

Description

@plamut

Calling StreamingPullFuture.cancel() invokes close() on the StreamingPullManager instance, but the latter method is now non-blocking as of version v2.4.1, meaning that StreamingPullFuture.cancel() has become non-blocking as well.

This can be problematic if subscriber client is used as a context manager, and cancelling the future is the last action in it. Exiting the with block closes the underlying transport, but the streaming pull shutdown might still be in progress. If a, say, NACK request is made during the shutdown after the transport has already been closed, an error occurs (user comment).

TL; DR - user should know that cancel() is non-blocking, and that the way to block on the shutdown is by calling the streaming_pull_future.result() method instead.

Also, at least one of the samples needs to be updated as well, but that's a separate issue.

Metadata

Metadata

Assignees

Labels

api: pubsubIssues related to the googleapis/python-pubsub API.type: docsImprovement to the documentation for an API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions