开发者

GAE WSGIApplication and multiple request

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

appl开发者_StackOverflow社区ication = 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?


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).


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: 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜