refactor: 修改默认worker计算方法 (#1761)
Some checks are pending
sync2gitee / repo-sync (push) Waiting to run
Typos Check / Spell Check with Typos (push) Waiting to run

This commit is contained in:
shaohuzhang1 2024-12-04 15:48:55 +08:00 committed by GitHub
parent a71adf15af
commit fd35ef281c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,3 +1,5 @@
import math
from django.core.management.base import BaseCommand
from django.db.models import TextChoices
@ -93,7 +95,8 @@ class BaseActionCommand(BaseCommand):
'services', nargs='+', choices=Services.export_services_values(), help='Service',
)
parser.add_argument('-d', '--daemon', nargs="?", const=True)
parser.add_argument('-w', '--worker', type=int, nargs="?", default=3 if os.cpu_count() > 3 else os.cpu_count())
parser.add_argument('-w', '--worker', type=int, nargs="?",
default=3 if os.cpu_count() > 6 else math.floor(os.cpu_count() / 2))
parser.add_argument('-f', '--force', nargs="?", const=True)
def initial_util(self, *args, **options):