From 5b7c71d4c42b1fd0f89a9c8abb5e827c1e7a7d23 Mon Sep 17 00:00:00 2001 From: Nicholas Carlini Date: Mon, 18 Mar 2024 19:32:08 -0700 Subject: [PATCH] Add try/catch to stop failures --- docker_controller.py | 8 ++++++-- evaluator.py | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docker_controller.py b/docker_controller.py index 02dee8bd..dc0213fe 100644 --- a/docker_controller.py +++ b/docker_controller.py @@ -165,9 +165,13 @@ def remove_ansi(text): def __call__(self, cmd): # Send the command through the PTY - self.process.stdin.write((cmd + "\n")) print("GO", self.process.stdin) - self.process.stdin.flush() + try: + self.process.stdin.write((cmd + "\n")) + self.process.stdin.flush() + except: + print("Process was terminated") + return "Process was terminated" # Read the output until the EOS string is encountered output = [] diff --git a/evaluator.py b/evaluator.py index 77165547..7ce99fe7 100644 --- a/evaluator.py +++ b/evaluator.py @@ -641,8 +641,8 @@ def __init__(self): pass def __call__(self, code): - #try: - if 1: + try: + #if 1: from selenium import webdriver from selenium.webdriver.chrome.options import Options @@ -680,7 +680,7 @@ def __call__(self, code): yield img_data, Reason(type(self), img_data) - try: + #try: pass except: