这是我第一次尝试在项目中使用asyncio。我希望我的类初始化并运行,它的几个函数定期“在后台”运行。我希望类‘init’在启动这些后台任务后返回,这样它就可以继续同时执行其同步任务。__init__(self)
asyncio.set_event_loop(self.loop)
asyncio.ensure_future(self.periodic(), lo
我正在构建一个web抓取API,我的大部分抓取都是用AsyncIO协同器完成的,如下所示: do scraping
asyncio.run(b.parse_event())
这非常好,但由于我是同时刮多个网站,我最初是使用concurrent.futures.ThreadPoolExecutor来使用多个线程的擦拭但是,由于我已经实现了coroutine逻辑,所以现在不能在线程中直接使用asyncio.run方