|
|
|
@ -65,6 +65,29 @@ def wrap_connection_loader__get(name, *args, **kwargs):
|
|
|
|
|
return connection_loader__get(name, *args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def patch_awx_callback():
|
|
|
|
|
"""
|
|
|
|
|
issue #400: AWX loads a display callback that suffers from thread-safety
|
|
|
|
|
issues. Detect the presence of older AWX versions and patch the bug.
|
|
|
|
|
"""
|
|
|
|
|
cls = ansible_mitogen.loaders.callback_loader.get(
|
|
|
|
|
'awx_display',
|
|
|
|
|
class_only=True,
|
|
|
|
|
)
|
|
|
|
|
if cls is None: # callback does not exist.
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
# Callback load will have updated sys.path. Now import its guts.
|
|
|
|
|
try:
|
|
|
|
|
from awx_display_callback.events import event_context
|
|
|
|
|
except ImportError:
|
|
|
|
|
return # Newer or ancient AWX.
|
|
|
|
|
|
|
|
|
|
# Executing this before starting additional threads avoids race.
|
|
|
|
|
with event_context.set_global():
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class StrategyMixin(object):
|
|
|
|
|
"""
|
|
|
|
|
This mix-in enhances any built-in strategy by arranging for various Mitogen
|
|
|
|
@ -164,6 +187,7 @@ class StrategyMixin(object):
|
|
|
|
|
ansible_mitogen.process.MuxProcess.start()
|
|
|
|
|
self._add_connection_plugin_path()
|
|
|
|
|
self._install_wrappers()
|
|
|
|
|
patch_awx_callback()
|
|
|
|
|
try:
|
|
|
|
|
return super(StrategyMixin, self).run(iterator, play_context)
|
|
|
|
|
finally:
|
|
|
|
|