[Notes] [Git][BuildStream/buildstream][master] 2 commits: _platform: Fix get_cpu_count() with cap=None



Title: GitLab

Jürg Billeter pushed to branch master at BuildStream / buildstream

Commits:

2 changed files:

Changes:

  • buildstream/_platform/darwin.py
    ... ... @@ -41,10 +41,11 @@ class Darwin(Platform):
    41 41
             return True
    
    42 42
     
    
    43 43
         def get_cpu_count(self, cap=None):
    
    44
    -        if cap < os.cpu_count():
    
    45
    -            return cap
    
    44
    +        cpu_count = os.cpu_count()
    
    45
    +        if cap is None:
    
    46
    +            return cpu_count
    
    46 47
             else:
    
    47
    -            return os.cpu_count()
    
    48
    +            return min(cpu_count, cap)
    
    48 49
     
    
    49 50
         def set_resource_limits(self, soft_limit=OPEN_MAX, hard_limit=None):
    
    50 51
             super().set_resource_limits(soft_limit)

  • buildstream/_platform/platform.py
    ... ... @@ -67,7 +67,11 @@ class Platform():
    67 67
             return cls._instance
    
    68 68
     
    
    69 69
         def get_cpu_count(self, cap=None):
    
    70
    -        return min(len(os.sched_getaffinity(0)), cap)
    
    70
    +        cpu_count = len(os.sched_getaffinity(0))
    
    71
    +        if cap is None:
    
    72
    +            return cpu_count
    
    73
    +        else:
    
    74
    +            return min(cpu_count, cap)
    
    71 75
     
    
    72 76
         ##################################################################
    
    73 77
         #                        Sandbox functions                       #
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]