diff --git a/src/cal_tools/tools.py b/src/cal_tools/tools.py index ae42e894f36f81776bef0b77f813b76f127e2938..615047957eea9b0f42b232902fbacfe74f0918af 100644 --- a/src/cal_tools/tools.py +++ b/src/cal_tools/tools.py @@ -1,5 +1,6 @@ import datetime import json +import os import re import zlib from collections import OrderedDict @@ -432,13 +433,17 @@ def save_const_to_h5(db_module: str, karabo_id: str, def get_random_db_interface(cal_db_interface): + """Return interface to calibration DB with + random (with given range) port. """ - Return interface to calibration DB with random (with given range) port. - """ + # Initialize the random generator with a random seed value, + # in case the function was executed within a multiprocessing pool. + np.random.seed() if "#" in cal_db_interface: prot, serv, ran = cal_db_interface.split(":") r1, r2 = ran.split("#") - return ":".join([prot, serv, str(np.random.randint(int(r1), int(r2)))]) + return ":".join( + [prot, serv, str(np.random.randint(int(r1), int(r2)))]) return cal_db_interface