는 다음 코드 작성 :토네이도 (파이썬) : HTTP 영구 연결에 대한 지속적인 HTTP 연결
class LongPolling(tornado.web.RequestHandler):
waiters = set()
def get(self):
LongPolling.waiters.add(self)
for x in LongPolling.waiters:
x.write("Broadcast all")
x.flush()
return
def on_close(self):
logging.warning("Connection closed *********")
LongPolling.waiters.remove(self)
if __name__ == "__main__":
application = tornado.web.Application([
(r"/", LongPolling),
])
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()
나는 새 연결이 올 때마다 braodcasting 오전 ..하지만이 문제는 get()
직후입니다 연결이 닫힙니다.
그래서 get()을 호출 한 후 연결을 열 수 있습니까?
당신은 [Socket.io의 토네이도 구현 (HTTPS를 사용하여 고려할 수 있습니다 : // github.com/MrJoes/tornadio) 당신의 목적에 과도하지 않다면. –
토네이도가 이러한 유형의 영구 연결을 지원하지 않는다는 뜻입니까? – user739711
@TokenMacGuy 내가 여기서 언급 한 것은 소켓 연결을 유지하는 방법이 있는지, 그래서 나중에 쓰는 방법이다. – user739711