Skip to content

Commit aa1bcc1

Browse files
committed
switch to aide offical method of timeout
1 parent 31122bf commit aa1bcc1

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

aide/interpreter.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -305,17 +305,16 @@ def run(self, code: str, reset_session=True) -> ExecutionResult:
305305
# read all stdout/stderr from child up to the EOF marker
306306
# waiting until the queue is empty is not enough since
307307
# the feeder thread in child might still be adding to the queue
308-
drain_start = time.time()
308+
start_collect = time.time()
309309
while not self.result_outq.empty() or not output or output[-1] != "<|EOF|>":
310-
logger.debug("[Parent] starting drain; qsize=%d", self.result_outq.qsize())
311310
try:
312-
output.append(self.result_outq.get(timeout=5))
311+
# Add 5-second timeout for output collection
312+
if time.time() - start_collect > 5:
313+
logger.warning("Output collection timed out")
314+
break
315+
output.append(self.result_outq.get(timeout=1))
313316
except queue.Empty:
314-
logger.error(
315-
"[Parent] drain timeout - q empty, no EOF after %ds",
316-
time.time() - drain_start,
317-
)
318-
break
317+
continue
319318
output.pop() # remove the EOF marker
320319

321320
e_cls_name, exc_info, exc_stack = state[1:]

0 commit comments

Comments
 (0)