File tree Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Original file line number Diff line number Diff line change 1
1
import json
2
+ import os
2
3
from collections .abc import Sequence
3
4
from enum import Enum
4
5
from typing import Literal , Optional
@@ -131,7 +132,9 @@ class Settings(BaseSettings):
131
132
132
133
# Scheduler settings
133
134
max_concurrency : int = 512
134
- max_worker_processes : int = 10
135
+ max_worker_processes : int = Field (
136
+ default_factory = lambda : max ((os .cpu_count () or 1 ) - 1 , 10 )
137
+ )
135
138
max_add_requests_per_loop : int = 20
136
139
scheduler_start_delay : float = 5
137
140
Original file line number Diff line number Diff line change 1
1
import math
2
- import os
3
2
import random
4
3
import time
5
4
from collections .abc import Generator
@@ -72,9 +71,7 @@ def processes_limit(self) -> int:
72
71
73
72
:return: The number of processes for the scheduling strategy.
74
73
"""
75
- cpu_cores = os .cpu_count () or 1
76
-
77
- return min (max (1 , cpu_cores - 1 ), settings .max_worker_processes )
74
+ return settings .max_worker_processes
78
75
79
76
@property
80
77
def queued_requests_limit (self ) -> Optional [int ]:
@@ -231,9 +228,8 @@ def processes_limit(self) -> int:
231
228
:return: {self.streams} for the concurrent scheduling strategy to limit
232
229
the worker processes to the number of streams.
233
230
"""
234
- cpu_cores = os .cpu_count () or 1
235
231
236
- return min (max ( 1 , cpu_cores - 1 ), self .streams )
232
+ return min (self .streams , settings . max_worker_processes )
237
233
238
234
@property
239
235
def queued_requests_limit (self ) -> int :
You can’t perform that action at this time.
0 commit comments