Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问如何解决 There is no current event loop in thread %r.' #356

Open
522315428 opened this issue Aug 14, 2024 · 3 comments
Open

请问如何解决 There is no current event loop in thread %r.' #356

522315428 opened this issue Aug 14, 2024 · 3 comments

Comments

@522315428
Copy link

error log | 日志或报错信息 | ログ

Exception in thread Thread-4 (run):
Traceback (most recent call last):
File "/home/pgpu/anaconda3/envs/Huixiangdou/lib/python3.10/threading.py", line 1009, in _bootstrap_inner
self.run()
File "/home/pgpu/anaconda3/envs/Huixiangdou/lib/python3.10/threading.py", line 946, in run
self._target(*self._args, **self._kwargs)
File "/home/pgpu/anaconda3/envs/Huixiangdou/lib/python3.10/site-packages/uvicorn/server.py", line 62, in run
return asyncio.run(self.serve(sockets=sockets))
File "/home/pgpu/anaconda3/envs/Huixiangdou/lib/python3.10/site-packages/nest_asyncio.py", line 26, in run
loop = asyncio.get_event_loop()
File "/home/pgpu/anaconda3/envs/Huixiangdou/lib/python3.10/site-packages/nest_asyncio.py", line 40, in _get_event_loop
loop = events.get_event_loop_policy().get_event_loop()
File "/home/pgpu/anaconda3/envs/Huixiangdou/lib/python3.10/asyncio/events.py", line 656, in get_event_loop
raise RuntimeError('There is no current event loop in thread %r.'

context | 编译/运行环境 | バックグラウンド

按照requirement 安装,运行本地大模型

how to reproduce | 复现步骤 | 再現方法

1.python3 -m huixiangdou.gradio --standalone

@tpoisonooo
Copy link
Collaborator

我猜你是在说这里:

image

@tpoisonooo
Copy link
Collaborator

@522315428 在这个函数前,其他地方调用过 asyncio.run()
run() 在结束后会销毁 loop,下次获取会失败。

把所有 asyncio.run() 改成不销毁的用法:

    loop = asyncio.get_event_loop()
    loop.run_until_complete(my_func())

@tpoisonooo
Copy link
Collaborator

@522315428 在这里一起改了,麻烦再试下。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants