views:

66

answers:

4

In dev_appserver

class MainPage(webapp.RequestHandler):
  def get(self):
     self.response.out.write("Hello MainPage")

class TestPage(webapp.RequestHandler):
  def get(self):
    # 10 seconds
    i = 1
    while True:
      if i == 10:
        break
      time.sleep(1)
      i = i + 1

application = webapp.WSGIApplication([
  ('/', MainPage)
  ('/test10', TestPage),
], debug=True)

I don't understand. I go to http://localhost:8080/test10 and go to http://localhost:8080/, but MainPage not execute. After 10 seconds, MainPage return "Hello MainPage". GAE server not support multiple request?

+1  A: 

The actual GAE web servers on Google's servers in the clouds support multiple requests easily (indeed their scalability is one of their strengths!), typically by using multiple processes and possibly multiple computers to divide up the load during periods of time in which many requests are coming in fast and furious.

The SDK running on your local computer, intended strictly to help you develop (definitely not to actually serve production traffic!-), serves requests one after the other instead, to make it easier for you to debug (directly, via the logs, etc, etc).

If you want to serve GAE apps yourself (from your own computer or data center), not for development purposes but for production, consider alternative implementations of the GAE APIs, such as appscale (probably more suitable if you have many servers available for the purpose, and the sysadm skill to deal with them) and typhoonae (probably more suitable if you have one or just a few servers to use and want less sysadm workload).

Alex Martelli
+1  A: 

You haven't included a main() method, or the 'magic' stanza that causes the first request to be handled correctly. Add the following to the end of your module:

def main():
  run_wsgi_app(application)

if __name__ == "__main__":
  main()
Nick Johnson
A: 

Thank you, Alex Martelli. Jetty server for GAE Java better than GAE Python dev_appserver. Moving from Python to Java, but I love Python and PHP.

Thank you, hungsimol http://code.google.com/p/googleappengine/issues/detail?id=3482

BLN
A: 

@Nick Johnson: You test it? Of course! My code included "run_wsgi_app" and "main" functions.

http://groups.google.com/group/google-appengine-python/browse_thread/thread/102d76f04ecc5155

BLN