removed threading

This commit is contained in:
Paul Gauthier 2023-06-24 15:59:50 -07:00
parent 197d8fe057
commit a5746d9e54

View file

@ -4,7 +4,6 @@ import json
import os
import shutil
import subprocess
import threading
import time
from json.decoder import JSONDecodeError
from pathlib import Path
@ -197,35 +196,11 @@ def run_test(testdir, model_name, edit_format, retries, no_test, verbose):
verbose=verbose,
)
coder_timeout = 120
dur = 0
test_outcomes = []
for i in range(retries):
def run_coder(stop_event):
try:
coder.run(with_message=instructions)
except Exception as e:
if stop_event.is_set():
print("Thread stopped due to timeout.")
else:
raise e
start = time.time()
stop_event = threading.Event()
coder_thread = threading.Thread(target=run_coder, args=(stop_event,))
coder_thread.start()
coder_thread.join(coder_timeout) # seconds timeout
if coder_thread.is_alive():
stop_event.set()
coder_thread.join() # Wait for the thread to exit gracefully
print(f"coder.run took longer than {coder_timeout} seconds and was stopped.")
# Handle the case when the coder.run call takes longer than 60 seconds
# You can raise an exception or handle it accordingly
# raise Exception("coder.run took longer than 60 seconds")
coder.run(with_message=instructions)
dur += time.time() - start
if coder.num_control_c: