Skip to content

Commit

Permalink
sched_getaffinity inclusion for availProcessors
Browse files Browse the repository at this point in the history
  • Loading branch information
WardDeb committed Jan 17, 2024
1 parent 9dd5c03 commit 11d48b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* initiate deprecation of tight_layout in plotheatmap, in favor of constrained_layout. Minor changes in paddings, etc can occur (but for the better).
* documentation changes to improve ESS tab, table constraints have been lifted & sphinx_rtd_theme to v2.0.0
* upload artifact in gh test runner pinned to 3
* Try to get the number of processors from sched_getaffinity, to avoid using to many in job submissions for example. #1199

3.5.4
* error handling and cases for bwAverage with >2 samples
Expand Down
10 changes: 7 additions & 3 deletions deeptools/parserCommon.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import argparse
import os
from importlib.metadata import version

import multiprocessing

def check_float_0_1(value):
v = float(value)
Expand Down Expand Up @@ -341,8 +341,12 @@ def getParentArgParse(args=None, binSize=True, blackList=True):


def numberOfProcessors(string):
import multiprocessing
availProc = multiprocessing.cpu_count()
try:
# won't work on macOS or windows
# limit threads to what is available (e.g. grid submissions, issue #1199)
availProc = len(os.sched_getaffinity(0))
except AttributeError:
availProc = multiprocessing.cpu_count()

if string == "max/2": # default case
# by default half of the available processors are used
Expand Down

0 comments on commit 11d48b6

Please sign in to comment.