I have a simple python script that uses Google pubsub to detect new files in the google cloud storage. The script simply adds new messages to a queue where another thread processes those messages:
subscriber = pubsub.SubscriberClient()
subscription_path = subscriber.subscription_path(
project, subscription_name)
subscriber.subscribe(subscription_path, callback=callback_fun)
while True:
if not message_queue:
time.sleep(60)
continue
else:
process_next_message(message_queue.pop())
Here, callback_fun simply adds the message to the queue:
def callback_fun(message):
message.ack()
message_queue.append(message)
The problem I am having is that after a while (maybe a couple of days), the subscriber stops receiving new file notifications. If I stop and restart the script, it gets all of the notifications at once.
I was wondering if anyone else is having similar issues and/or can suggest ways to troubleshoot (maybe by printing debugging messages that are normally unseen). I am now trying to stop/restart the subscriber, but I am sure that this is not the best idea for using in a production environment.
I am using google-cloud 0.32.0 and google-cloud-pubsub 0.30.1.
In general, there can be several reasons why a subscriber may stop receiving messages:
If your problem does not fall into one of those categories, it would be best to reach out to Google Cloud support with your project name, topic name, and subscription name so that they can narrow down the issue to either your user code, the client library, or the service.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With