moved last utils.debug to display.debug

pull/15347/head
Brian Coca 9 years ago
parent dd32ba406a
commit 005dc84aa7

@ -35,7 +35,12 @@ try:
except ImportError:
HAS_ATFORK=False
from ansible.utils.debug import debug
try:
from __main__ import display
except ImportError:
from ansible.utils.display import Display
display = Display()
__all__ = ['ResultProcess']
@ -57,9 +62,9 @@ class ResultProcess(multiprocessing.Process):
super(ResultProcess, self).__init__()
def _send_result(self, result):
debug(u"sending result: %s" % ([text_type(x) for x in result],))
display.debug(u"sending result: %s" % ([text_type(x) for x in result],))
self._final_q.put(result)
debug("done sending result")
display.debug("done sending result")
def _read_worker_result(self):
result = None
@ -72,9 +77,9 @@ class ResultProcess(multiprocessing.Process):
try:
if not rslt_q.empty():
debug("worker %d has data to read" % self._cur_worker)
display.debug("worker %d has data to read" % self._cur_worker)
result = rslt_q.get()
debug("got a result from worker %d: %s" % (self._cur_worker, result))
display.debug("got a result from worker %d: %s" % (self._cur_worker, result))
break
except queue.Empty:
pass

@ -46,10 +46,14 @@ from ansible.executor.task_result import TaskResult
from ansible.playbook.handler import Handler
from ansible.playbook.task import Task
from ansible.vars.unsafe_proxy import AnsibleJSONUnsafeDecoder
from ansible.utils.debug import debug
from ansible.utils.unicode import to_unicode
try:
from __main__ import display
except ImportError:
from ansible.utils.display import Display
display = Display()
__all__ = ['WorkerProcess']
@ -104,7 +108,7 @@ class WorkerProcess(multiprocessing.Process):
try:
# execute the task and build a TaskResult from the result
debug("running TaskExecutor() for %s/%s" % (self._host, self._task))
display.debug("running TaskExecutor() for %s/%s" % (self._host, self._task))
executor_result = TaskExecutor(
self._host,
self._task,
@ -116,15 +120,15 @@ class WorkerProcess(multiprocessing.Process):
self._rslt_q
).run()
debug("done running TaskExecutor() for %s/%s" % (self._host, self._task))
display.debug("done running TaskExecutor() for %s/%s" % (self._host, self._task))
self._host.vars = dict()
self._host.groups = []
task_result = TaskResult(self._host, self._task, executor_result)
# put the result on the result queue
debug("sending task result")
display.debug("sending task result")
self._rslt_q.put(task_result)
debug("done sending task result")
display.debug("done sending task result")
except AnsibleConnectionFailure:
self._host.vars = dict()
@ -140,8 +144,8 @@ class WorkerProcess(multiprocessing.Process):
task_result = TaskResult(self._host, self._task, dict(failed=True, exception=to_unicode(traceback.format_exc()), stdout=''))
self._rslt_q.put(task_result, block=False)
except:
debug(u"WORKER EXCEPTION: %s" % to_unicode(e))
debug(u"WORKER TRACEBACK: %s" % to_unicode(traceback.format_exc()))
display.debug(u"WORKER EXCEPTION: %s" % to_unicode(e))
display.debug(u"WORKER TRACEBACK: %s" % to_unicode(traceback.format_exc()))
debug("WORKER PROCESS EXITING")
display.debug("WORKER PROCESS EXITING")

@ -39,7 +39,6 @@ from ansible.plugins import filter_loader, lookup_loader, test_loader
from ansible.template.safe_eval import safe_eval
from ansible.template.template import AnsibleJ2Template
from ansible.template.vars import AnsibleJ2Vars
from ansible.utils.debug import debug
from ansible.utils.unicode import to_unicode, to_str
try:
@ -499,7 +498,7 @@ class Templar:
errmsg += "Make sure your variable name does not contain invalid characters like '-': %s" % to_str(te)
raise AnsibleUndefinedVariable(errmsg)
else:
debug("failing because of a type error, template data is: %s" % to_str(data))
display.debug("failing because of a type error, template data is: %s" % to_str(data))
raise AnsibleError("Unexpected templating type error occurred on (%s): %s" % (to_str(data),to_str(te)))
if preserve_trailing_newlines:

@ -1,18 +0,0 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
import time
import sys
from multiprocessing import Lock
from ansible import constants as C
global_debug_lock = Lock()
def debug(msg):
if C.DEFAULT_DEBUG:
global_debug_lock.acquire()
print("%6d %0.5f: %s" % (os.getpid(), time.time(), msg))
sys.stdout.flush()
global_debug_lock.release()

@ -7,7 +7,10 @@ from multiprocessing import Process, Manager, Pipe, RLock
from ansible.playbook.play import Play
from ansible.playbook.task import Task
from ansible.utils.debug import debug
from ansible.utils.display import Display
display = Display()
debug = display.debug
NUM_WORKERS = 50
NUM_HOSTS = 2500

@ -16,7 +16,9 @@ from ansible.executor.task_result import TaskResult
from ansible.parsing.dataloader import DataLoader
from ansible.vars import VariableManager
from ansible.utils.debug import debug
from ansible.utils.display import Display
display = Display()
debug = display.debug
NUM_WORKERS = 20
NUM_HOSTS = 1778

Loading…
Cancel
Save