Commit bde5ed96 by James Cammarata

Catch worker errors that may be subclassed on others that lead to incorrect exits

parent 053c41e7
...@@ -20,6 +20,7 @@ from __future__ import (absolute_import, division, print_function) ...@@ -20,6 +20,7 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
from six.moves import queue from six.moves import queue
import multiprocessing import multiprocessing
import os import os
import signal import signal
...@@ -27,6 +28,8 @@ import sys ...@@ -27,6 +28,8 @@ import sys
import time import time
import traceback import traceback
from jinja2.exceptions import TemplateNotFound
# TODO: not needed if we use the cryptography library with its default RNG # TODO: not needed if we use the cryptography library with its default RNG
# engine # engine
HAS_ATFORK=True HAS_ATFORK=True
...@@ -127,8 +130,6 @@ class WorkerProcess(multiprocessing.Process): ...@@ -127,8 +130,6 @@ class WorkerProcess(multiprocessing.Process):
except queue.Empty: except queue.Empty:
pass pass
except (IOError, EOFError, KeyboardInterrupt):
break
except AnsibleConnectionFailure: except AnsibleConnectionFailure:
try: try:
if task: if task:
...@@ -138,13 +139,16 @@ class WorkerProcess(multiprocessing.Process): ...@@ -138,13 +139,16 @@ class WorkerProcess(multiprocessing.Process):
# FIXME: most likely an abort, catch those kinds of errors specifically # FIXME: most likely an abort, catch those kinds of errors specifically
break break
except Exception as e: except Exception as e:
debug("WORKER EXCEPTION: %s" % e) if isinstance(e, (IOError, EOFError, KeyboardInterrupt)) and not isinstance(e, TemplateNotFound):
debug("WORKER EXCEPTION: %s" % traceback.format_exc()) break
else:
try: try:
if task: if task:
task_result = TaskResult(host, task, dict(failed=True, exception=traceback.format_exc(), stdout='')) task_result = TaskResult(host, task, dict(failed=True, exception=traceback.format_exc(), stdout=''))
self._rslt_q.put(task_result, block=False) self._rslt_q.put(task_result, block=False)
except: except:
debug("WORKER EXCEPTION: %s" % e)
debug("WORKER EXCEPTION: %s" % traceback.format_exc())
# FIXME: most likely an abort, catch those kinds of errors specifically # FIXME: most likely an abort, catch those kinds of errors specifically
break break
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment