Skip to content

Commit

Permalink
QA
Browse files Browse the repository at this point in the history
  • Loading branch information
ajinabraham committed Nov 4, 2024
1 parent 799cf6f commit 78587c1
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions libsast/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,12 @@ def read_yaml(file_obj, text=False):

def get_worker_count():
"""Get worker count for pool."""
# Default to 1 worker
worker_count = 1

# Try to get the CPU count
libsast_workers = os.getenv('LIBSAST_WORKERS')
if libsast_workers:
try:
return int(libsast_workers)
except ValueError:
return 1
try:
worker_count = os.cpu_count()
except Exception:
Expand All @@ -86,13 +88,4 @@ def get_worker_count():
# Adjust worker count for Windows
if sys.platform == 'win32':
worker_count = min(worker_count, 61)

# Override with environment variable if set
libsast_workers = os.getenv('LIBSAST_WORKERS')
if libsast_workers is not None:
try:
worker_count = int(libsast_workers)
except ValueError:
worker_count = 1

return worker_count

0 comments on commit 78587c1

Please sign in to comment.