You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 9, 2026. It is now read-only.
It is reported that the issue does not occur with in PubSub version v0.45.0. Update: However, this could not be confirmed. Confirmed by @HemangChothani
Steps to reproduce
Create a topic.
Create a subscription.
With no messages published to the topic, perform a synchronous pull.
Actual result:
After a few seconds a 504 DeadlineExceeded exception is raised.
Expected result:
Assuming that the network functions normally, there should be no error, and the subscriber.pull() should simply return an empty list of messages.
Mind that there is no error if the return_immediately=True flag is used, but the latter is set to be deprecated and should thus not be used.
Code sample
The following script might be useful:
reproduce.py
importloggingimportosimportthreadingimporttimefromgoogle.cloudimportpubsub_v1script_dir=os.path.dirname(os.path.realpath(__file__))
log_filename=os.path.join(script_dir, "subscriber.log")
log_format= (
"%(levelname)-8s [%(asctime)s] %(threadName)-33s ""[%(name)s] [%(filename)s:%(lineno)d][%(funcName)s] %(message)s"
)
logging.basicConfig(
level=logging.DEBUG,
format=log_format,
)
logger=logging.getLogger(__name__)
PROJECT_NAME="my-project"TOPIC_NAME="my-events"SUBSCRIPTION_NAME=f"subscription_{TOPIC_NAME}"defmain():
subscriber=pubsub_v1.SubscriberClient()
subscription_path=subscriber.subscription_path(PROJECT_NAME, SUBSCRIPTION_NAME)
topic_path=subscriber.topic_path(PROJECT_NAME, TOPIC_NAME)
# TODO: if topic does not exist, you must first create itsubscriber.create_subscription(name=subscription_path, topic=topic_path)
print("Starting a pull...")
response=subscriber.pull(
subscription_path, max_messages=3,
# return_immediately=True
)
received_messages=response.received_messagesifnotreceived_messages:
print("No messages received")
returnprint("response >>", response)
formessageinresponse.received_messages:
print(message.message.data.decode("utf-8"))
print("Sending ACK...")
subscriber.acknowledge(
subscription_path, [msg.ack_idformsginresponse.received_messages]
)
print("... ACK sent.")
if__name__=="__main__":
main()
Forked from googleapis/google-cloud-python#7709 (comment).
Environment details
Tested with the following:
Steps to reproduce
Actual result:
After a few seconds a 504 DeadlineExceeded exception is raised.
Expected result:
Assuming that the network functions normally, there should be no error, and the
subscriber.pull()should simply return an empty list of messages.Mind that there is no error if the
return_immediately=Trueflag is used, but the latter is set to be deprecated and should thus not be used.Code sample
The following script might be useful:
reproduce.py