Commit f905fd4d authored by Thomas Vincent's avatar Thomas Vincent

Use default n_proc instead of cpu_count during merge

parent b3eec347
......@@ -38,13 +38,14 @@ import os.path
import ctypes
from threading import Thread
import multiprocessing.sharedctypes as mp_sharedctypes
from multiprocessing import Pool, cpu_count, Manager
from multiprocessing import Pool, Manager
import h5py
import numpy as np
import fabio
from import XsocsH5
from ... import config
_logger = logging.getLogger(__name__)
......@@ -121,7 +122,7 @@ class KmapMerger(object):
self.__spec_h5 = spec_h5
self.__callback = callback
self.__n_proc = None
self.__n_proc = config.DEFAULT_PROCESS_NUMBER
self.__compression = 'lzf'
self.__prefix = 'prefix'
self.__overwrite = False
......@@ -254,15 +255,10 @@ class KmapMerger(object):
with XsocsH5.XsocsH5MasterWriter(master_f, mode=mode):
if self.__n_proc is None:
n_proc = cpu_count()
n_proc = self.__n_proc
# setting progress to 0
np.frombuffer(self.__shared_progress, dtype='int32')[:] = 0
pool = Pool(n_proc,
pool = Pool(self.n_proc,
......@@ -530,14 +526,12 @@ class KmapMerger(object):
def n_proc(self, n_proc):
if n_proc is None:
self.__n_proc = None
if n_proc is None: # Use default
n_proc = int(n_proc)
if n_proc <= 0:
self.__n_proc = None
raise ValueError('n_proc must be strictly positive')
self.__n_proc = n_proc
......@@ -90,10 +90,10 @@ def merge_scan_data(output_dir,
:type img_dir: *optional* str
:param n_proc: Number of threads to use when merging files. If None, the
number of threads used will be the value returned by the function
:type n_proc: *optional* str
:param Union[int,None] n_proc:
Number of threads to use when merging files.
If None, the number of processes used will be the
default config value (usually the number of cores).
:param version: version of the spec file. It is currently used to get
the offset and padding to apply to the nextNr value found in the spec scan
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment