- with open(in_file, 'rb') as rb:
- serialized = rb.read()
-
- fun, args, kwargs = cloudpickle.loads(serialized)
+ stop_thread = None
+ if config.config['watch_for_cancel']:
+ (thread, stop_thread) = watch_for_cancel()
+
+ logger.debug(f'Reading {in_file}.')
+ try:
+ with open(in_file, 'rb') as rb:
+ serialized = rb.read()
+ except Exception as e:
+ logger.exception(e)
+ logger.critical(f'Problem reading {in_file}. Aborting.')
+ stop_thread.set()
+ sys.exit(-1)
+
+ logger.debug(f'Deserializing {in_file}.')
+ try:
+ fun, args, kwargs = cloudpickle.loads(serialized)
+ except Exception as e:
+ logger.exception(e)
+ logger.critical(f'Problem deserializing {in_file}. Aborting.')
+ stop_thread.set()
+ sys.exit(-1)
+
+ logger.debug('Invoking user code...')
+ start = time.time()