prepared skeleton for lab5
This commit is contained in:
@@ -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())
|
||||
Reference in New Issue
Block a user