Skip to content

Commit 8ba581d

Browse files
committed
chore: shutdown method
1 parent 06cdecb commit 8ba581d

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

openagent/cli.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import asyncio
22
import os
3+
import sys
34
import click
45
import uvicorn
56

@@ -15,6 +16,21 @@ def shutdown():
1516
os._exit(0)
1617

1718

19+
if sys.platform == "win32":
20+
import threading
21+
import time
22+
import msvcrt
23+
24+
def check_exit_windows():
25+
while True:
26+
if msvcrt.kbhit() and msvcrt.getch().decode("utf-8").lower() == "q":
27+
shutdown()
28+
time.sleep(1)
29+
30+
# Start the exit checker thread
31+
threading.Thread(target=check_exit_windows, daemon=True).start()
32+
33+
1834
@click.group()
1935
def cli():
2036
"""OpenAgent CLI tool"""

0 commit comments

Comments
 (0)