Skip to content

Commit 1928586

Browse files
Add "Scheduler.optimal_process_count()"
1 parent 35e34a1 commit 1928586

2 files changed

Lines changed: 8 additions & 23 deletions

File tree

scheduler/Scheduler.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def __init__(
7171
self.output: List[tuple] = []
7272

7373
# Minimum number of tasks to run concurrently.
74-
self.min_concurrent_count: int = cpu_count() + 1
74+
self.min_concurrent_count: int = self.optimal_process_count()
7575

7676
# The actual number of tasks may be adjusted dynamically to improve efficiency.
7777
self.concurrent_count: int = self.min_concurrent_count
@@ -176,6 +176,13 @@ def is_running(self) -> bool:
176176
""":returns whether the scheduler is running."""
177177
return self.started and not self.finished and not self.terminated
178178

179+
@staticmethod
180+
def optimal_process_count() -> int:
181+
"""
182+
:returns the optimal number of processes based on the number of logical processors.
183+
"""
184+
return cpu_count() + 1
185+
179186
def _initialize_output(self) -> None:
180187
# Initialize `self.output` so that it can be indexed into.
181188
self.output = [None for _ in self.tasks]

scheduler/__init__.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)