Skip to content

Commit 8025e0b

Browse files
committed
Have rm_run_path() delete in parallell
1 parent a8a163b commit 8025e0b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/ert/run_models/base_run_model.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import asyncio
4+
import concurrent.futures
45
import copy
56
import dataclasses
67
import functools
@@ -88,6 +89,11 @@ class ErtRunError(Exception):
8889
pass
8990

9091

92+
def delete_runpath(run_path: str) -> None:
93+
if os.path.exists(run_path):
94+
shutil.rmtree(run_path)
95+
96+
9197
class _LogAggregration(logging.Handler):
9298
def __init__(self, messages: MutableSequence[str]) -> None:
9399
self.messages = messages
@@ -696,9 +702,8 @@ def get_number_of_successful_realizations(self) -> int:
696702

697703
@log_duration(logger, logging.INFO)
698704
def rm_run_path(self) -> None:
699-
for run_path in self.paths:
700-
if Path(run_path).exists():
701-
shutil.rmtree(run_path)
705+
with concurrent.futures.ThreadPoolExecutor() as executor:
706+
executor.map(delete_runpath, self.paths)
702707

703708
def validate_successful_realizations_count(self) -> None:
704709
successful_realizations_count = self.get_number_of_successful_realizations()

0 commit comments

Comments
 (0)