mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-31 12:54:29 +01:00
Added feature to interrupt y -N continuous commands. (#4230)
* Added feature to interrupt y -N continuous commands. * Fixed formatting. --------- Co-authored-by: Nicholas Tindle <nick@ntindle.com>
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import signal
|
||||
import sys
|
||||
from datetime import datetime
|
||||
|
||||
from colorama import Fore, Style
|
||||
@@ -88,6 +90,20 @@ class Agent:
|
||||
arguments = None
|
||||
user_input = ""
|
||||
|
||||
# Signal handler for interrupting y -N
|
||||
def signal_handler(signum, frame):
|
||||
if self.next_action_count == 0:
|
||||
sys.exit()
|
||||
else:
|
||||
print(
|
||||
Fore.RED
|
||||
+ "Interrupt signal received. Stopping continuous command execution."
|
||||
+ Style.RESET_ALL
|
||||
)
|
||||
self.next_action_count = 0
|
||||
|
||||
signal.signal(signal.SIGINT, signal_handler)
|
||||
|
||||
while True:
|
||||
# Discontinue if continuous limit is reached
|
||||
self.cycle_count += 1
|
||||
|
||||
Reference in New Issue
Block a user