mirror of https://github.com/Mai-with-u/MaiBot.git
非TTY环境禁用console_input_loop
parent
6dee5a6333
commit
2d2f6ecd8d
8
bot.py
8
bot.py
|
|
@ -314,10 +314,16 @@ if __name__ == "__main__":
|
||||||
# Schedule tasks returns a future that runs forever.
|
# Schedule tasks returns a future that runs forever.
|
||||||
# We can run console_input_loop concurrently.
|
# We can run console_input_loop concurrently.
|
||||||
main_tasks = loop.create_task(main_system.schedule_tasks())
|
main_tasks = loop.create_task(main_system.schedule_tasks())
|
||||||
|
# 仅在 TTY 中启用 console_input_loop
|
||||||
|
if sys.stdin.isatty():
|
||||||
|
logger.info("检测到终端环境,启用控制台输入循环")
|
||||||
console_task = loop.create_task(console_input_loop(main_system))
|
console_task = loop.create_task(console_input_loop(main_system))
|
||||||
|
|
||||||
# Wait for all tasks to complete (which they won't, normally)
|
# Wait for all tasks to complete (which they won't, normally)
|
||||||
loop.run_until_complete(asyncio.gather(main_tasks, console_task))
|
loop.run_until_complete(asyncio.gather(main_tasks, console_task))
|
||||||
|
else:
|
||||||
|
logger.info("非终端环境,跳过控制台输入循环")
|
||||||
|
# Wait for all tasks to complete (which they won't, normally)
|
||||||
|
loop.run_until_complete(main_tasks)
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
# loop.run_until_complete(get_global_api().stop())
|
# loop.run_until_complete(get_global_api().stop())
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue