mirror of
https://github.com/RockChinQ/QChatGPT.git
synced 2024-11-16 19:57:04 +08:00
暴力修复程序无法退出的bug
This commit is contained in:
parent
e0caeb5dd2
commit
3aca987176
19
main.py
19
main.py
|
@ -228,10 +228,13 @@ def start(first_time_init=False):
|
||||||
"捕捉到未知异常:{}, 请前往 https://github.com/RockChinQ/QChatGPT/issues 查找或提issue".format(e))
|
"捕捉到未知异常:{}, 请前往 https://github.com/RockChinQ/QChatGPT/issues 查找或提issue".format(e))
|
||||||
known_exception_caught = True
|
known_exception_caught = True
|
||||||
raise e
|
raise e
|
||||||
|
threading.Thread(
|
||||||
pkg.utils.context.get_thread_ctl().submit_sys_task(
|
target=run_bot_wrapper
|
||||||
run_bot_wrapper
|
).start()
|
||||||
)
|
# 机器人暂时不能放在线程池中
|
||||||
|
# pkg.utils.context.get_thread_ctl().submit_sys_task(
|
||||||
|
# run_bot_wrapper
|
||||||
|
# )
|
||||||
finally:
|
finally:
|
||||||
if first_time_init:
|
if first_time_init:
|
||||||
if not known_exception_caught:
|
if not known_exception_caught:
|
||||||
|
@ -378,8 +381,12 @@ def main():
|
||||||
except:
|
except:
|
||||||
stop()
|
stop()
|
||||||
pkg.utils.context.get_thread_ctl().shutdown()
|
pkg.utils.context.get_thread_ctl().shutdown()
|
||||||
print("退出")
|
import platform
|
||||||
sys.exit(0)
|
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__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user