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

RuntimeError: cannot schedule new futures after interpreter shutdown请问这个问题怎么解决? #321

Open
yxn4065 opened this issue Apr 6, 2024 · 2 comments
Assignees
Labels
operation problem 用户操作问题

Comments

@yxn4065
Copy link

yxn4065 commented Apr 6, 2024

确认已寻找过答案

我已确认在 Github issue 页、常见问题页、文档 中都查找过,没有找到类似问题和资料。我也没有 google / bing/ 百度 / duckduckgo 到相关解答。

这个错误信息表明在 Python 解释器关闭后,尝试调度新的 concurrent.futures.Future 对象时发生了异常。具体来说,在 Conversation.py 文件的 _tts 方法中,当尝试使用线程池(pool)的 submit 方法提交新任务时,Python 解释器已经处于关闭状态,因此不允许再调度新的任务。

这种情况通常发生在以下几种情况:

程序正在退出,而某个线程或回调尝试提交新任务。
使用了信号处理器来优雅地关闭程序,但在关闭过程中,仍有代码尝试提交新任务。
程序的其他部分存在资源管理问题,导致解释器过早关闭。

安装方式

手动安装

操作系统

树莓派4B 64bit

离线唤醒相关

问题描述

2024-04-06 13:18:09,707 - tornado.application - web.py - log_exception - line 1871 - ERROR - Uncaught exception POST /chat (192.168.137.1)
HTTPServerRequest(protocol='http', host='192.168.137.252:5001', method='POST', uri='/chat', version='HTTP/1.1', remote_ip='192.168.137.1')
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.11/site-packages/tornado/web.py", line 1784, in _execute
result = method(*self.path_args, **self.path_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/souce_code/wukong-robot/server/server.py", line 170, in post
conversation.doResponse(
File "/home/pi/souce_code/wukong-robot/robot/Conversation.py", line 173, in doResponse
self.say(msg, True, onCompleted=self.checkRestore)
File "/home/pi/souce_code/wukong-robot/robot/Conversation.py", line 405, in say
audios = self._tts(lines, cache, onCompleted)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/souce_code/wukong-robot/robot/Conversation.py", line 316, in _tts
task = pool.submit(
^^^^^^^^^^^^
File "/usr/lib/python3.11/concurrent/futures/thread.py", line 169, in submit
raise RuntimeError('cannot schedule new futures after '
RuntimeError: cannot schedule new futures after interpreter shutdown
2024-04-06 13:18:09,718 - tornado.access - web.py - log_request - line 2344 - ERROR - 500 POST /chat (192.168.137.1) 2760.01ms

开始时候正常,第二次对话无应答,提示服务器错误
image

@yxn4065 yxn4065 added the operation problem 用户操作问题 label Apr 6, 2024
@Potential-Progress
Copy link

问题有解决吗?

@gravelandblood
Copy link

根本原因是主线程已经结束了,而子线程去尝试一个新的任务,解决办法很简单:
在server/server.py的run方法里,t.start()下面加一行:t.join(),就可以等子线程结束再结束主线程

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
operation problem 用户操作问题
Projects
None yet
Development

No branches or pull requests

4 participants