mirror of
https://github.com/RockChinQ/QChatGPT.git
synced 2024-11-16 11:42:44 +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))
|
||||
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()
|
||||
|
|
Loading…
Reference in New Issue
Block a user