From 8d4661bdc9c90d69d09952542140892caeeae2a4 Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Fri, 2 Feb 2024 17:55:25 +0100 Subject: [PATCH] pyocf: rio: Introduce copy() This allows to create a Rio prototype object and the copy it for every invocations so that some parameters can be overwritten without modifying the prototype object itself. Signed-off-by: Robert Baldyga Signed-off-by: Michal Mielewczyk --- tests/functional/pyocf/rio.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/functional/pyocf/rio.py b/tests/functional/pyocf/rio.py index fe8827a..ec9e3fd 100644 --- a/tests/functional/pyocf/rio.py +++ b/tests/functional/pyocf/rio.py @@ -11,7 +11,7 @@ from dataclasses import dataclass, field from datetime import timedelta, datetime from itertools import cycle from threading import Thread, Condition, Event -from copy import deepcopy +import copy from pyocf.utils import Size from pyocf.types.volume import Volume @@ -173,6 +173,11 @@ class Rio: self.errors = {} self.error_count = 0 + def copy(self): + r = copy.copy(self) + r.global_jobspec = copy.copy(self.global_jobspec) + return r + def readwrite(self, rw: ReadWrite): self.global_jobspec.readwrite = rw return self @@ -269,7 +274,7 @@ class Rio: def run_async(self, queues): self.clear() - jobs = deepcopy(self.jobs) + jobs = copy.deepcopy(self.jobs) if not jobs: jobs = [self.global_jobspec for _ in range(self.global_jobspec.njobs)]