Skip to content

Commit aa31b60

Browse files
committed
fix: kill all created pids
1 parent 229bd32 commit aa31b60

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

bigcodebench/eval/utils.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,19 @@ def safe_exec(*args, **kwargs):
221221
try:
222222
yield
223223
finally:
224-
# Restore original functions after the block
224+
for pid in child_pids:
225+
try:
226+
os.kill(pid, signal.SIGTERM)
227+
os.waitpid(pid, 0)
228+
except ProcessLookupError:
229+
pass # Process already terminated
230+
except Exception as e:
231+
print(f"Error terminating process {pid}: {e}")
232+
try:
233+
os.kill(pid, signal.SIGKILL)
234+
except Exception:
235+
pass
236+
225237
os.kill = original_kill
226238
os.killpg = original_killpg
227239
os.system = original_system

0 commit comments

Comments
 (0)