prepared skeleton for lab5

This commit is contained in:
2026-11-07 16:10:32 +03:00
parent 276dbdad8a
commit 0a70358829
135 changed files with 9647 additions and 34 deletions
+24
View File
@@ -0,0 +1,24 @@
"""Одноразовый Linux-процесс декодирования с пределами памяти и 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())