Is anyone else seeing this?  I noticed that global variables were getting 
modified mid-execution and then confirmed by checking os.getpid() and saw 
the same process IDs in two concurrent requests (using time.sleep() to 
force concurrency)

Meanwhile, I drafted up a quick workaround - it seems to work, but I'd love 
a code review!

import logging
from os import getpid
from threading import Lock
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
...
class SingleThreadedWSGIApplication(webapp.WSGIApplication):
  def __init__(self, *args, **kwargs):
    self.lock = Lock()
    super(SingleThreadedWSGIApplication, self).__init__(*args, **kwargs)
  def __call__(self, environ, start_response):
    logging.warning("SingleThreadedWSGIApplication.__call__().  pid=%d" % 
getpid())
    with self.lock:
      return super(SingleThreadedWSGIApplication, self).__call__(environ, 
start_response)

def is_production():
  ...bunch of custom environment checks...

PATHS=[ ... ]

app = SingleThreadedWSGIApplication(PATHS, debug=(not is_production()))

def main():
   ...
   run_wsgi_app(app)

if __name__ == "__main__":
  main()


relevant parts of app.yaml:

runtime: python-compat
vm: true
entrypoint: gunicorn -b :$PORT main:app
*threadsafe: false*
api_version: 1
instance_class: F4


-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/97529bb1-a0d3-4b31-b2ad-89fd32697c36%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to