feat: лимит конкурентных сканов через asyncio.Semaphore
- config.py: MAX_CONCURRENT_SCANS (default=4) - harvester.py: глобальный _scan_semaphore оборачивает scan_package() — при N одновременных сканах, (N+1)-й будет ждать освобождения слота — download и SHA256 не лимитируются, только guarddog subprocess - docker-compose.yml, .env.example: переменная добавлена
This commit is contained in:
@@ -25,6 +25,9 @@ from guarddog_nexus.scanner import scan_package
|
||||
_url_locks: dict[str, asyncio.Lock] = {}
|
||||
_url_lock = asyncio.Lock()
|
||||
|
||||
# Global semaphore to limit concurrent GuardDog processes
|
||||
_scan_semaphore = asyncio.Semaphore(config.max_concurrent_scans)
|
||||
|
||||
|
||||
async def harvest(
|
||||
download_url: str,
|
||||
@@ -118,7 +121,8 @@ async def harvest(
|
||||
return scan
|
||||
|
||||
log.info("Scanning %s==%s", package_name, package_version)
|
||||
result = await scan_package(downloaded, ecosystem)
|
||||
async with _scan_semaphore:
|
||||
result = await scan_package(downloaded, ecosystem)
|
||||
|
||||
findings_list = result.get("findings", [])
|
||||
created_findings: list[Finding] = []
|
||||
|
||||
Reference in New Issue
Block a user