Closed mukund-ananthu closed 5 months ago
For non-retriable errors returned from the backend, the client library currently sets future.set_exception() for all outstanding futures:
https://github.com/googleapis/python-pubsub/blob/8c7e2a9e1b158e2b75dec8c5d78be17ce2dd449b/google/cloud/pubsub_v1/publisher/_batch/thread.py#L285-L286
before it tries to change its state to paused by calling the _batch_done_callback(): https://github.com/googleapis/python-pubsub/blob/8c7e2a9e1b158e2b75dec8c5d78be17ce2dd449b/google/cloud/pubsub_v1/publisher/_batch/thread.py#L289-L291
This results in race conditions where the callback associated with the future is invoked before the client enters paused state. Which causes issues if the callback attempts to do a resume_publish() before the client is in the paused state.
For non-retriable errors returned from the backend, the client library currently sets future.set_exception() for all outstanding futures:
https://github.com/googleapis/python-pubsub/blob/8c7e2a9e1b158e2b75dec8c5d78be17ce2dd449b/google/cloud/pubsub_v1/publisher/_batch/thread.py#L285-L286
before it tries to change its state to paused by calling the _batch_done_callback(): https://github.com/googleapis/python-pubsub/blob/8c7e2a9e1b158e2b75dec8c5d78be17ce2dd449b/google/cloud/pubsub_v1/publisher/_batch/thread.py#L289-L291
This results in race conditions where the callback associated with the future is invoked before the client enters paused state. Which causes issues if the callback attempts to do a resume_publish() before the client is in the paused state.