抱歉,标题略含糊.
有两个返回json接口
http://example.com/api/user/uidhttp://example.com/api/user/uid/fun本打算如此实现 handles
(r'/api/user/(.*)', user.fun1),
(r'/api/user/(.*)/fun2', user.fun2 ),
搞了半天,发现 user.fun1 根本不会调用 ......
于是乎改为这样
(r'/api/user/(.*)', user.funs ),
class funs(BaseController):
@
tornado.web.asynchronous
def get(self, params):
if 'fun' in params:
self.fun2
else:
self.fun1
惊奇的发现 it works !!!(虽然很山寨...)
重点来了 !!!!
客户端两个接口先后几乎同时请求
self.fun1 self.fun2最后都会调用 self.finish(),
于是乎出现了 finish() called twice - - !
后来看到有说法@
tornado.web.asynchronous 是不可以self.finish()的
于是乎改为self.fun1 self.fun2最后都调用 self.write(),
没有 finish() called twice了,但是有一个接口一直没数据返回(单独请求任意一个都正常!)
醉了醉了....
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
https://www.v2ex.com/t/199311
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.