python 在子线程中开启websever(使用aiohttp)linux系统下报错 set_wakeup_fd only works in main thread

class websever (threading.Thread):
def init(self, threadID, name):
threading.Thread.__init__(self)
self.threadID = threadID
self.name = name
self.loop=asyncio.new_event_loop()
def getloop(self):
return self.loop
def run(self):
print ("开始线程:" + self.name)
# asyncio.get_child_watcher()
asyncio.set_event_loop(self.loop)
app = web.Application()
app.add_routes([web.get('/wssev', fun.websocket_handler1),
web.get('/probe', fun.probe),
web.get('/flash',fun.getflash),
web.get('/force',fun.force_trade_day),
web.get('/reset',fun.reset),
])
asyncio.run(web.run_app(app, port=9999))


1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐