title: How come my Flask app returns a 500 server error when deployed with a new file in memory?
body: <p>I'm deploying a new version of my Flask application to Google App Engine (GAE) and am receiving a 500 server error before the home page even loads. The only difference in this new version is that I am loading an <em>additional</em> 26MB file into memory using the <code>@app.before_first_request</code> decorator. In the previous, working version, I was loading in files in the same manner that amounted to 20MB at most.</p>
  
  <p>Before loading in this file, my app was working well in production.</p>
  
  <p>I have tried to update my app.yaml file to increase the size of the machine by adding in the following lines:</p>
  
  <pre><code>resources:
    cpu: 2
    memory_gb: 2.3
  </code></pre>
  
  <p>This is my app.yaml file:</p>
  
  <pre><code>runtime: python27
  api_version: 1
  threadsafe: true
  
  handlers:
  - url: /static
    static_dir: static
  - url: /.*
    script: main.app
  
  libraries:
  - name: ssl
    version: latest
  - name: numpy
    version: "1.6.1"
  
  resources:
    cpu: 2
    memory_gb: 2.3
  </code></pre>
  
  <p>This is how I am loading the files into memory in main.py:</p>
  
  <pre><code>def get_gcloud_data(fname):
      """Retrieve file from GCS.
      """
      base_link = 'http://fake_base_link/'
      return pickle.loads(requests.get(base_link+fname).content)
  
  @app.before_first_request
  def startup():
      global fake_var_name
  
      fake_var_name = np.array(get_gcloud_data('pickled_file.p'))
  </code></pre>
  
  <p>I did not expect this additional file to cause such problems. Am I loading files into memory incorrectly (should I be doing this at all?)? How come I am getting this new 500 error?</p>