title: How to call a global variable from a pubsub callback function in google-cloud-platform vminstance?
body: <p>I'm running a neural network model that supposed to run in callback function every time asynchronously when a pubsub event is triggered. I loaded the model as global variable, during the initialization of main program, so that it can access in any function and to avoid model loading every time in callback function itself.
  Typical code can be:  </p>
  
  <pre><code>global cv_model
  cv_model = load_model('my_model.h5')
  
  def callback():
      prediction = cv_model.predict(image)
  </code></pre>
  
  <p>This method works perfectly in my local machine. But when I tried with pubsub event call back I'm getting some errors. After some search I figured out 'pubsub is a child-process of the main program and we cannot share global variables between processes'. I tried nested-function approach and OOPs approach but none of them worked. </p>
  
  <p>How can I avoid model loading everytime when callback function being called?
  Any alternative methods to resolve this conflict?</p>
  
  <p>Thanks for the suggestions!!</p>