Remove ruffus 2.6.3 exception special casing

This commit is contained in:
James R. Barlow 2018-07-09 13:56:23 -07:00
parent d6eb1f9578
commit 338593d9e7

View File

@ -659,36 +659,31 @@ def do_ruffus_exception(ruffus_five_tuple, options, log):
return ExitCode.other_error return ExitCode.other_error
def traverse_ruffus_exception(e_args, options, log): def traverse_ruffus_exception(exceptions, options, log):
"""Walk through a RethrownJobError and find the first exception. """Traverse a RethrownJobError and output the exceptions
Ruffus flattens exception to 5 element tuples. Because of a bug Ruffus presents exceptions as 5 element tuples. The RethrownJobException
in <= 2.6.3 it may present either the single: has a list of exceptions like
(task, job, exc, value, stack) e.job_exceptions = [(5-tuple), (5-tuple), ...]
or something like:
[[(task, job, exc, value, stack)]]
For Ruffus > 2.6.4 the RethrownJobException has a list of exceptions like ruffus < 2.7.0 had a bug with exception marshalling that would give
e.job_exceptions = [(5-tuple), (5-tuple), ...] different output whether the main or child process raised the exception.
We no longer support this.
Generally cross-process exception marshalling doesn't work well Attempting to log the exception itself will re-marshall it to the logger
and ruffus doesn't support because BaseException has its own which is normally running in another process. It's better to avoid re-
implementation of __reduce__ that attempts to reconstruct the marshalling.
exception based on e.__init__(e.args).
Attempting to log the exception directly marshalls it to the logger
which is probably in another process, so it's better to log only
data from the exception at this point.
The exit code will be based on this, even if multiple exceptions occurred The exit code will be based on this, even if multiple exceptions occurred
at the same time.""" at the same time."""
if isinstance(e_args, Sequence) and isinstance(e_args[0], str) \ exit_codes = []
and len(e_args) == 5: for exc in exceptions:
return do_ruffus_exception(e_args, options, log) exit_code = do_ruffus_exception(exceptions, options, log)
elif is_iterable_notstr(e_args): exit_codes.append(exit_code)
for exc in e_args:
return traverse_ruffus_exception(exc, options, log) return exit_codes[0] # Multiple codes are rare so take the first one
def check_closed_streams(options): def check_closed_streams(options):
@ -904,10 +899,7 @@ def run_pipeline():
except ruffus_exceptions.RethrownJobError as e: except ruffus_exceptions.RethrownJobError as e:
if options.verbose: if options.verbose:
_log.debug(str(e)) # stringify exception so logger doesn't have to _log.debug(str(e)) # stringify exception so logger doesn't have to
if hasattr(e, 'job_exceptions'): exceptions = e.job_exceptions
exceptions = e.job_exceptions
else:
exceptions = e.args # ruffus 2.6.3
exitcode = traverse_ruffus_exception(exceptions, options, _log) exitcode = traverse_ruffus_exception(exceptions, options, _log)
if exitcode is None: if exitcode is None:
_log.error("Unexpected ruffus exception: " + str(e)) _log.error("Unexpected ruffus exception: " + str(e))