title: Google Cloud Pub/Sub Python SDK retrieve single message at a time
body: <p><strong>Problem</strong>: My use case is I want to receive messages from Google Cloud Pub/Sub - one message at a time using the Python Api. All the current examples mention using Async/callback option for pulling the messages from a Pub/Sub subscription. The problem with that approach is I need to keep the thread alive. </p>
  
  <p>Is it possible to just receive 1 message and close the connection i.e. is there a feature where I can just set a parameter (something like a <code>max_messages</code>) to 1 so that once it receives 1 message the thread terminates?</p>
  
  <p>The documentation <a href="https://cloud.google.com/pubsub/docs/pull#synchronous-pull" rel="nofollow noreferrer">here</a> doesn't list anything for Python Synchronous pull which seem to have <code>num_of_messages</code> option for other languages like Java.</p>