From 3aca98717681e3997630767620d0d08276215ec9 Mon Sep 17 00:00:00 2001 From: LINSTCL Date: Fri, 10 Mar 2023 09:35:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=B4=E5=8A=9B=E4=BF=AE=E5=A4=8D=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E6=97=A0=E6=B3=95=E9=80=80=E5=87=BA=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index da5d1831..131aff75 100644 --- a/main.py +++ b/main.py @@ -228,10 +228,13 @@ def start(first_time_init=False): "捕捉到未知异常:{}, 请前往 https://github.com/RockChinQ/QChatGPT/issues 查找或提issue".format(e)) known_exception_caught = True raise e - - pkg.utils.context.get_thread_ctl().submit_sys_task( - run_bot_wrapper - ) + threading.Thread( + target=run_bot_wrapper + ).start() + # 机器人暂时不能放在线程池中 + # pkg.utils.context.get_thread_ctl().submit_sys_task( + # run_bot_wrapper + # ) finally: if first_time_init: if not known_exception_caught: @@ -378,8 +381,12 @@ def main(): except: stop() pkg.utils.context.get_thread_ctl().shutdown() - print("退出") - sys.exit(0) + import platform + if platform.system() == 'Windows': + cmd = "taskkill /F /PID {}".format(os.getpid()) + elif platform.system() in ['Linux', 'Darwin']: + cmd = "kill -9 {}".format(os.getpid()) + os.system(cmd) if __name__ == '__main__': main()