Merge pull request #4201 from cchurch/callback-shenanigans

Fix callback plugin issues
This commit is contained in:
Chris Church 2016-12-01 15:18:21 -05:00 committed by GitHub
commit a5c0d5a0f9
2 changed files with 9 additions and 2 deletions

View File

@ -28,9 +28,14 @@ import psutil
__all__ = []
main_pid = os.getpid()
@atexit.register
def terminate_ssh_control_masters():
# Only run this cleanup from the main process.
if os.getpid() != main_pid:
return
# Determine if control persist is being used and if any open sockets
# exist after running the playbook.
cp_path = os.environ.get('ANSIBLE_SSH_CONTROL_PATH', '')

View File

@ -123,7 +123,7 @@ class EventContext(object):
def get_end_dict(self):
return {}
def dump(self, fileobj, data, max_width=78):
def dump(self, fileobj, data, max_width=78, flush=False):
b64data = base64.b64encode(json.dumps(data))
with self.display_lock:
fileobj.write(u'\x1b[K')
@ -132,12 +132,14 @@ class EventContext(object):
escaped_chunk = u'{}\x1b[{}D'.format(chunk, len(chunk))
fileobj.write(escaped_chunk)
fileobj.write(u'\x1b[K')
if flush:
fileobj.flush()
def dump_begin(self, fileobj):
self.dump(fileobj, self.get_begin_dict())
def dump_end(self, fileobj):
self.dump(fileobj, self.get_end_dict())
self.dump(fileobj, self.get_end_dict(), flush=True)
event_context = EventContext()