How to subscribe to GCP Pub/Sub when running a server of Django?

Viewed 762

I have a backend service using django, I need to subscribe a message queue hosted on GCP pub/sub

Here's the example code provided by Google: https://cloud.google.com/pubsub/docs/pull

Implementing a function is easy,

but I will have to start the django server via the command like:

python manage.py runserver

Or ASGI commands

This subscribing function should be running continuously, better in the background,

How can I achieve this?

I have tried django-crontab or django-background-task, but either of these needs to run commands manually, I don't think this is what I need.

0 Answers
Related