add --jobs option to autoupdate

This commit is contained in:
Anthony Sottile 2023-04-29 15:05:17 -04:00
parent bab5f70a38
commit ddbee32ad0
4 changed files with 72 additions and 43 deletions

View file

@ -3,6 +3,7 @@ from __future__ import annotations
import concurrent.futures
import contextlib
import math
import multiprocessing
import os
import subprocess
import sys
@ -22,6 +23,13 @@ TArg = TypeVar('TArg')
TRet = TypeVar('TRet')
def cpu_count() -> int:
try:
return multiprocessing.cpu_count()
except NotImplementedError:
return 1
def _environ_size(_env: MutableMapping[str, str] | None = None) -> int:
environ = _env if _env is not None else getattr(os, 'environb', os.environ)
size = 8 * len(environ) # number of pointers in `envp`