Julius Unverfehrt 501fd48d69 Adjust error handling of processing sub-process
Removes exception catching when collecting subprocess result which led
to the service silently go over failing file processing.

Now, the sub-process doesn't return any results if it failed. It is made
sure that an empty result is still returned if no images were present on
the file to process.
2023-08-17 13:26:27 +02:00

23 lines
541 B
Python

import logging
import multiprocessing
logger = logging.getLogger("main")
def wrap_in_process(fn):
manager = multiprocessing.Manager()
return_queue = manager.list()
def process_fn(*args, **kwargs):
return_queue.append(fn(*args, **kwargs))
def wrapped_fn(*args, **kwargs):
logger.debug("Starting new subprocess")
process = multiprocessing.Process(target=process_fn, args=args, kwargs=kwargs)
process.start()
process.join()
return return_queue.pop(0)
return wrapped_fn