Commit ba481d8d authored by Ripinder Singh's avatar Ripinder Singh
Browse files

Add lock to mld csv writing

parent aa602a0c
Loading
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ import subprocess
import tempfile
import sys
from typing import Tuple
from multiprocessing import Pool
from multiprocessing import Pool, Lock
from dataclasses import dataclass
from typing import Union
import shutil
@@ -50,6 +50,7 @@ import filecmp

sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))

mldLock = Lock()

def readfile(
    filename: str, nchannels: int = 1, fs: int = 48000, outdtype="float"
@@ -849,8 +850,11 @@ class MLDConformance:
                    np.array([f"{pytestTag}-FRM{x}" for x in range(mldThisFile.size)]),
                )
            )
            global mldLock
            with mldLock:
                with open(self.mldcsv[tag], "ab") as f:
                    np.savetxt(f, mldWithTags, fmt="%s", delimiter=",")

            with open(self.sampleStats[tag], "a") as f:
                f.write(
                    f"{pytestTag}, {maxDiff}, {rmsdB}, {beSamplesPercent}, {mldThisFile.max()}\n"