GAE WSGIApplication 和多重请求
在 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)
我不明白。我转到 http://localhost:8080/test10 并转到 http://localhost:8080/,但 MainPage 不执行。 10 秒后,MainPage 返回“Hello MainPage”。 GAE服务器不支持多个请求?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Google 云端服务器上的实际 GAE Web 服务器可以轻松支持多个请求(事实上,它们的可扩展性是它们的优势之一!),通常通过使用多个进程和可能的多台计算机来在多个请求同时处理的时间段内分配负载。来得又快又猛。
在本地计算机上运行的 SDK 严格旨在帮助您开发(绝对不是实际服务生产流量!-),而是一个接一个地服务请求,以便您更轻松地调试(直接、通过日志等) , ETC)。
如果您想自己(从您自己的计算机或数据中心)提供 GAE 应用程序,不是为了开发目的而是为了生产,请考虑 GAE API 的替代实现,例如 appscale (如果您有许多可用于此目的的服务器,并且具有处理它们的 sysadm 技能,则可能更合适)和 typhoonae(如果您有一台或几台服务器可供使用并且希望减少 sysadm 工作负载,则可能更合适)。
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).
您尚未包含 main() 方法,或导致正确处理第一个请求的“神奇”节。将以下内容添加到模块的末尾:
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:
@Nick Johnson:你测试过吗?当然!我的代码包括“run_wsgi_app”和“main”函数。
http://groups.google.com/group/google- appengine-python/browse_thread/thread/102d76f04ecc5155
@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