【发布时间】:2020-08-18 03:57:56
【问题描述】:
这里有两个简单的RequestHandlers:
class AsyncHandler(tornado.web.RequestHandler):
@gen.coroutine
def get(self):
while True:
future = Future()
global_futures.add(future)
s = yield future
self.write(s)
self.flush()
class AsyncHandler2(tornado.web.RequestHandler):
@gen.coroutine
def get(self):
for f in global_futures:
f.set_result(str(dt.now()))
global_futures.clear()
self.write("OK")
第一个“订阅”流,第二个将消息传递给所有订阅者。
问题是我不能拥有超过一堆(在我的情况下是 5-6 个)订阅者。一旦我订阅超过允许的数量,对第二种方法的下一个请求就会挂起。
我认为这是由于第一个处理程序没有正确异步而发生的。那是因为我使用全局对象来存储订阅者列表吗?
如何同时打开更多流式传输请求,什么是逻辑限制?
【问题讨论】:
-
问题与题目无关,原问题在这里讨论-stackoverflow.com/questions/985431/…
标签: python tornado concurrent.futures