Johnserf-Seed / f2

High-speed downloader for multiple platforms
https://johnserf-seed.github.io/f2/
Apache License 2.0
551 stars 109 forks source link

[BUG]RuntimeError: There is no current event loop in thread 'MainThread' #159

Open OldPengTou opened 4 months ago

OldPengTou commented 4 months ago

详细描述错误 简明扼要地描述遇到的错误。

系统平台

单击展开 Q:你在哪个平台(Win/Linux/Mac)上运行?你使用的是什么浏览器?你使用的是什么终端软件?你使用的F2是什么版本? A: - 操作系统: Win11 - 浏览器 Chrome - 终端 [Windows Terminal](https://aka.ms/terminal) - F2版本 0.0.1.6

错误重现

单击展开 Q: 请你复制并粘贴出错时运行的命令和配置文件内容,以及重现该行为的步骤。如果你一次性就提供完整信息,就会节省很多解决问题的时间。 A: 1. F:\Environment\Python\python-3.9.0-amd64\Lib\site-packages\f2\conf>f2 dy -c conf/dyshangjia0728.yaml INFO 您当前使用的是最新版本:0.0.1.6 INFO 应用:douyin INFO 模式:one INFO 主配置路径:f:\environment\python\python-3.9.0-amd64\lib\site-packages\f2\conf\app.yaml INFO 自定义配置路径:F:\Environment\Python\python-3.9.0-amd64\Lib\site-packages\f2\conf\conf\dyshangjia0728.yaml Traceback (most recent call last): File "f:\environment\python\python-3.9.0-amd64\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "f:\environment\python\python-3.9.0-amd64\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "F:\Environment\Python\python-3.9.0-amd64\Scripts\f2.exe\__main__.py", line 7, in sys.exit(main()) File "f:\environment\python\python-3.9.0-amd64\lib\site-packages\click\core.py", line 1157, in __call__ return self.main(*args, **kwargs) File "f:\environment\python\python-3.9.0-amd64\lib\site-packages\click\core.py", line 1078, in main rv = self.invoke(ctx) File "f:\environment\python\python-3.9.0-amd64\lib\site-packages\click\core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "f:\environment\python\python-3.9.0-amd64\lib\site-packages\click\core.py", line 1434, in invoke return ctx.invoke(self.callback, **ctx.params) File "f:\environment\python\python-3.9.0-amd64\lib\site-packages\click\core.py", line 783, in invoke return __callback(*args, **kwargs) File "f:\environment\python\python-3.9.0-amd64\lib\site-packages\click\decorators.py", line 33, in new_func return f(get_current_context(), *args, **kwargs) File "f:\environment\python\python-3.9.0-amd64\lib\site-packages\f2\apps\douyin\cli.py", line 441, in douyin ctx.invoke(set_cli_config, **kwargs) File "f:\environment\python\python-3.9.0-amd64\lib\site-packages\click\core.py", line 783, in invoke return __callback(*args, **kwargs) File "f:\environment\python\python-3.9.0-amd64\lib\site-packages\click\decorators.py", line 33, in new_func return f(get_current_context(), *args, **kwargs) File "f:\environment\python\python-3.9.0-amd64\lib\site-packages\f2\cli\cli_commands.py", line 178, in set_cli_config SignalManager().register_shutdown_signal() File "f:\environment\python\python-3.9.0-amd64\lib\site-packages\f2\utils\_singleton.py", line 21, in __call__ instance = super().__call__(*args, **kwargs) File "f:\environment\python\python-3.9.0-amd64\lib\site-packages\f2\utils\_signal.py", line 11, in __init__ self._shutdown_event = asyncio.Event() File "f:\environment\python\python-3.9.0-amd64\lib\asyncio\locks.py", line 177, in __init__ self._loop = events.get_event_loop() File "f:\environment\python\python-3.9.0-amd64\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 'MainThread'. 2. 3. Q: 请添加调试命令`f2 -d DEBUG`重新运行出错的命令并提供日志目录下的日志文件。 A: Q: 如果是开发者请提供最小的代码示例 A: ```python ```

预期行为 简明扼要地描述期望发生的事情。

屏幕截图 请添加截图以帮助解释你的问题。

日志文件 请添加调试日志文件以帮助解释你的问题。

其他 如有,可以添加有关问题的其他信息。

OnClickListener2048 commented 3 months ago

same here

sasvageangelss1 commented 1 month ago

替换完之后 ImportError: cannot import name 'check_f2_version' from 'f2.utils.utils'

lanybass commented 1 month ago

依然报错

PS I:\douyindown> f2 dy -c .\my_apps.yaml WARNING 您当前使用的版本 0.0.1.6 可能已过时,请考虑及时升级到最新版本 0.0.1.6,请使用 pip install -U f2 更新 INFO 应用:douyin INFO 模式:post INFO 主配置路径:d:\python39\lib\site-packages\f2\conf\app.yaml INFO 自定义配置路径:I:\douyindown\my_apps.yaml Traceback (most recent call last): File "d:\python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "d:\python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "D:\Python39\Scripts\f2.exe__main.py", line 7, in sys.exit(main()) File "d:\python39\lib\site-packages\click\core.py", line 1157, in call return self.main(*args, kwargs) File "d:\python39\lib\site-packages\click\core.py", line 1078, in main rv = self.invoke(ctx) File "d:\python39\lib\site-packages\click\core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "d:\python39\lib\site-packages\click\core.py", line 1434, in invoke return ctx.invoke(self.callback, ctx.params) File "d:\python39\lib\site-packages\click\core.py", line 783, in invoke return callback(*args, kwargs) File "d:\python39\lib\site-packages\click\decorators.py", line 33, in new_func return f(get_current_context(), args, kwargs) File "d:\python39\lib\site-packages\f2\apps\douyin\cli.py", line 441, in douyin ctx.invoke(set_cli_config, kwargs) File "d:\python39\lib\site-packages\click\core.py", line 783, in invoke return __callback(args, kwargs) File "d:\python39\lib\site-packages\click\decorators.py", line 33, in new_func return f(get_current_context(), *args, *kwargs) File "d:\python39\lib\site-packages\f2\cli\cli_commands.py", line 180, in set_cli_config SignalManager().register_shutdown_signal() File "d:\python39\lib\site-packages\f2\utils_singleton.py", line 21, in call instance = super().call(args, **kwargs) File "d:\python39\lib\site-packages\f2\utils_signal.py", line 11, in init self._shutdown_event = asyncio.Event() File "d:\python39\lib\asyncio\locks.py", line 177, in init self._loop = events.get_event_loop() File "d:\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 'MainThread'.

lanybass commented 1 month ago

我改回上一版的代码反而可以运行了: 把 get_command中的asyncio.run(check_version())改回:

from concurrent.futures import ThreadPoolExecutor def run_async_in_thread(coro): """在单独的线程中运行异步任务""" loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) executor = ThreadPoolExecutor(max_workers=1) executor.submit(run_async_in_thread, check_version)

ciring commented 2 weeks ago

same 安装的的0.0.1.7

╭────────────────────────────────────────────────────────────────────────────────── F2 版本检查 ──────────────────────────────────────────────────────────────────────────────────╮ │ 您当前使用的是最新版本:0.0.1.6 │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ INFO 应用:douyin INFO 模式:one INFO 主配置路径:C:\Users\chenruisi\Documents\f2-0.0.1.7-pw2\f2-0.0.1.7-pw2\f2\conf\app.yaml INFO 自定义配置路径:C:\Users\chenruisi\Documents\f2-0.0.1.7-pw2\f2-0.0.1.7-pw2\f2\conf\app.yaml Traceback (most recent call last): File "C:\Users\chenruisi\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\chenruisi\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\chenruisi\AppData\Local\Programs\Python\Python39\Scripts\f2.exe__main.py", line 7, in sys.exit(main()) File "C:\Users\chenruisi\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1157, in call return self.main(*args, kwargs) File "C:\Users\chenruisi\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1078, in main rv = self.invoke(ctx) File "C:\Users\chenruisi\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "C:\Users\chenruisi\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1434, in invoke return ctx.invoke(self.callback, ctx.params) File "C:\Users\chenruisi\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 783, in invoke return callback(*args, kwargs) File "C:\Users\chenruisi\AppData\Local\Programs\Python\Python39\lib\site-packages\click\decorators.py", line 33, in new_func return f(get_current_context(), args, kwargs) File "C:\Users\chenruisi\Documents\f2-0.0.1.7-pw2\f2-0.0.1.7-pw2\f2\apps\douyin\cli.py", line 481, in douyin ctx.invoke(set_cli_config, kwargs) File "C:\Users\chenruisi\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 783, in invoke return __callback(args, kwargs) File "C:\Users\chenruisi\AppData\Local\Programs\Python\Python39\lib\site-packages\click\decorators.py", line 33, in new_func return f(get_current_context(), *args, *kwargs) File "C:\Users\chenruisi\Documents\f2-0.0.1.7-pw2\f2-0.0.1.7-pw2\f2\cli\cli_commands.py", line 172, in set_cli_config SignalManager().register_shutdown_signal() File "C:\Users\chenruisi\Documents\f2-0.0.1.7-pw2\f2-0.0.1.7-pw2\f2\utils_singleton.py", line 21, in call instance = super().call(args, **kwargs) File "C:\Users\chenruisi\Documents\f2-0.0.1.7-pw2\f2-0.0.1.7-pw2\f2\utils_signal.py", line 11, in init self._shutdown_event = asyncio.Event() File "C:\Users\chenruisi\AppData\Local\Programs\Python\Python39\lib\asyncio\locks.py", line 177, in init self._loop = events.get_event_loop() File "C:\Users\chenruisi\AppData\Local\Programs\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 'MainThread'.

Johnserf-Seed commented 2 weeks ago

python的版本不匹配会导致异步事件兼容性问题,推荐升级到 Python 3.10 或更高版本

Johnserf-Seed commented 2 weeks ago

same 安装的的0.0.1.7

╭────────────────────────────────────────────────────────────────────────────────── F2 版本检查 ──────────────────────────────────────────────────────────────────────────────────╮ │ 您当前使用的是最新版本:0.0.1.6 │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ INFO 应用:douyin INFO 模式:one INFO 主配置路径:C:\Users\chenruisi\Documents\f2-0.0.1.7-pw2\f2-0.0.1.7-pw2\f2\conf\app.yaml INFO 自定义配置路径:C:\Users\chenruisi\Documents\f2-0.0.1.7-pw2\f2-0.0.1.7-pw2\f2\conf\app.yaml Traceback (most recent call last): File "C:\Users\chenruisi\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\chenruisi\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\chenruisi\AppData\Local\Programs\Python\Python39\Scripts\f2.exemain.py", line 7, in sys.exit(main()) File "C:\Users\chenruisi\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1157, in call return self.main(args, kwargs) File "C:\Users\chenruisi\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1078, in main rv = self.invoke(ctx) File "C:\Users\chenruisi\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "C:\Users\chenruisi\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1434, in invoke return ctx.invoke(self.callback, ctx.params) File "C:\Users\chenruisi\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 783, in invoke return __callback(args, kwargs) File "C:\Users\chenruisi\AppData\Local\Programs\Python\Python39\lib\site-packages\click\decorators.py", line 33, in new_func return f(get_current_context(), args, kwargs) File "C:\Users\chenruisi\Documents\f2-0.0.1.7-pw2\f2-0.0.1.7-pw2\f2\apps\douyin\cli.py", line 481, in douyin ctx.invoke(set_cli_config, kwargs) File "C:\Users\chenruisi\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 783, in invoke return __callback(args, kwargs) File "C:\Users\chenruisi\AppData\Local\Programs\Python\Python39\lib\site-packages\click\decorators.py", line 33, in new_func return f(get_current_context(), *args, kwargs) File "C:\Users\chenruisi\Documents\f2-0.0.1.7-pw2\f2-0.0.1.7-pw2\f2\cli\cli_commands.py", line 172, in set_cli_config SignalManager().register_shutdown_signal() File "C:\Users\chenruisi\Documents\f2-0.0.1.7-pw2\f2-0.0.1.7-pw2\f2\utils_singleton.py", line 21, in call instance = super().call*(args, kwargs) File "C:\Users\chenruisi\Documents\f2-0.0.1.7-pw2\f2-0.0.1.7-pw2\f2\utils_signal.py", line 11, in init self._shutdown_event = asyncio.Event() File "C:\Users\chenruisi\AppData\Local\Programs\Python\Python39\lib\asyncio\locks.py", line 177, in init** self._loop = events.get_event_loop() File "C:\Users\chenruisi\AppData\Local\Programs\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 'MainThread'.

不支持3.9版本了