def processor(preprocessed_data_id, param_id, param_constructor): """Dispatch the processor work""" preprocessed_data = PreprocessedData(preprocessed_data_id) params = param_constructor(param_id) sp = StudyProcessor() try: process_out = sp(preprocessed_data, params) except Exception as e: error_msg = ''.join(format_exception_only(e, exc_info())) preprocessed_data.processing_status = "failed: %s" % error_msg process_out = None return process_out