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.