noneplugin / nonebot-plugin-memes

Nonebot2 表情包制作插件
MIT License
224 stars 20 forks source link

首次运行时下载资源报错 #33

Closed cby120 closed 1 year ago

cby120 commented 1 year ago

nonebot version: 2.0.0rc2 nonebot-plugin-memes version: 0.3.9 driver为aiohttp和websockets 同类的petpet插件可以正常运行

Traceback (most recent call last):
  File "D:\lib\Python\Python39\lib\site-packages\nonebot\drivers\_block_driver.py", line 64, in serve
    await self.startup()
> File "D:\lib\Python\Python39\lib\site-packages\nonebot\drivers\_block_driver.py", line 80, in startup
    await asyncio.gather(*cors)
  File "D:\lib\Python\Python39\lib\site-packages\nonebot\utils.py", line 113, in _wrapper
    result = await loop.run_in_executor(None, pfunc)
  File "D:\lib\Python\Python39\lib\concurrent\futures\thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "D:\lib\Python\Python39\lib\site-packages\nonebot_plugin_petpet\download.py", line 88, in _
    asyncio.ensure_future(check_resources())
  File "D:\lib\Python\Python39\lib\asyncio\tasks.py", line 664, in ensure_future
    loop = events.get_event_loop()
  File "D:\lib\Python\Python39\lib\asyncio\events.py", line 642, in get_event_loop
    raise RuntimeError('There is no current event loop in thread %r.'
RuntimeError: There is no current event loop in thread 'asyncio_0'.

D:\lib\Python\Python39\lib\asyncio\base_events.py:1890: RuntimeWarning: coroutine 'check_resources' was never awaited
  handle = self._ready.popleft()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

补充,直接调用nonebot_plugin_memes.download.await check_resources()可以正常下载资源,可能是asyncio.ensure_future(check_resources())处的问题


更正,nonebot-plugin-petpet也出现了同样的报错


更新,只有在使用ForwardDriver时会出现上述错误,使用ReverseDriver时不会报错

MeetWq commented 1 year ago

看上去是driver的问题,你的driver是怎么写的

cby120 commented 1 year ago

driver为aiohttp和websockets

配置文件里面写的是DRIVER=~aiohttp+~websockets aiohttp version: 3.8.3 websockets version: 10.4 依赖安装都是在pip install nonebot2的时候自动安装的

MeetWq commented 1 year ago

按照 66f0eb4484a9993339763f3b77ab42020ead4a12 中的修改方式可以解决

cby120 commented 1 year ago

按照 66f0eb4 中的修改方式可以解决

已解决