This commit is contained in:
k00kzaAntonovaIra
2026-11-22 19:55:50 +03:00
parent 470d9d6f1e
commit 2d10a9b788
186 changed files with 15732 additions and 425 deletions
+24
View File
@@ -0,0 +1,24 @@
"""Дочерний процесс декодирования с пределами памяти и CPU"""
from pathlib import Path
import resource
import sys
from app.domain.image_validation import decode_image
from app.errors.exceptions import IMAGE_WORKER_ERRORS, image_worker_error_code
def main() -> int:
resource.setrlimit(resource.RLIMIT_AS, (512 * 1024 * 1024, 512 * 1024 * 1024))
resource.setrlimit(resource.RLIMIT_CPU, (10, 10))
path, content_type, maximum = sys.argv[1:]
status = 0
try:
decode_image(Path(path), content_type, int(maximum))
except IMAGE_WORKER_ERRORS as error:
status = image_worker_error_code(error)
return status
if __name__ == "__main__":
raise SystemExit(main())