Skip to content

Commit

Permalink
Merge pull request #128 from qiyunzhu/bugfix
Browse files Browse the repository at this point in the history
using MacOS-compatible CPU count
  • Loading branch information
qiyunzhu authored Sep 21, 2023
2 parents e8045fe + 230fb77 commit ea9fa72
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions hgtector/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
# The full license is in the file LICENSE, distributed with this software.
# ----------------------------------------------------------------------------

import os
import re
from os import remove, makedirs, sched_getaffinity
from os import remove, makedirs
from os.path import join, isdir, isfile
from shutil import which, rmtree
from tempfile import mkdtemp
Expand Down Expand Up @@ -131,8 +132,13 @@ def __call__(self, args):
# read and validate input data
self.input_wf()

# check available threads
try:
m = len(os.sched_getaffinity(0))
except AttributeError:
m = os.cpu_count()

# check requested threads if set vs available ones
m = len(sched_getaffinity(0))
if self.threads and self.threads > m:
print(
f'WARNING: Threads limited to {m} (requested {self.threads}).')
Expand Down

0 comments on commit ea9fa72

Please sign in to comment.