from tornado.concurrent import run_on_executor
@run_on_executor
def Timing_send(self, cmd):
while 1:
self.sendMsg(cmd)
time.sleep(1)
网上找了几个帖子都讲的不明确,如何在tornado里正确的使用多线程
from tornado.concurrent import run_on_executor
@run_on_executor
def Timing_send(self, cmd):
while 1:
self.sendMsg(cmd)
time.sleep(1)
网上找了几个帖子都讲的不明确,如何在tornado里正确的使用多线程
你是不是在后台线程处理的,
试试这个
from tornado.platform.asyncio import AnyThreadEventLoopPolicy asyncio.set_event_loop_policy(AnyThreadEventLoopPolicy())