Skip to content

Commit

Permalink
Default to os count of cpus.
Browse files Browse the repository at this point in the history
  • Loading branch information
Knucklessg1 committed Feb 18, 2023
1 parent e36b605 commit 6e440ce
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions repository_manager/repository_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self):
self.repository_directory = f"{os.getcwd()}"
self.git_projects = []
self.set_to_default_branch = False
self.threads = 4
self.threads = os.cpu_count()

def git_action(self, command, directory=None):
if directory is None:
Expand Down Expand Up @@ -44,14 +44,14 @@ def set_default_branch(self, set_to_default_branch):
def set_threads(self, threads):
try:
threads = int(threads)
if threads > 0:
if threads > 0 or threads < os.cpu_count():
self.threads = threads
else:
print(f"Did not recognize {threads} as a valid value, defaulting to 4")
self.threads = 4
print(f"Did not recognize {threads} as a valid value, defaulting to CPU Count: {os.cpu_count()}")
self.threads = os.cpu_count()
except Exception as e:
print(f"Did not recognize {threads} as a valid value, defaulting to 4\nError: {e}")
self.threads = 4
print(f"Did not recognize {threads} as a valid value, defaulting to CPU Count: {os.cpu_count()}\nError: {e}")
self.threads = os.cpu_count()

def append_git_project(self, git_project):
self.git_projects.append(git_project)
Expand Down Expand Up @@ -109,7 +109,7 @@ def repository_manager(argv):
directory = os.curdir
file = None
repositories = None
threads = 4
threads = os.cpu_count()
try:
opts, args = getopt.getopt(argv, "hbcpd:f:r:t:",
["help", "default-branch", "clone", "pull", "directory=", "file=", "repositories=",
Expand Down

0 comments on commit 6e440ce

Please sign in to comment.