@ -236,6 +236,41 @@ class MuxProcess(object):
if secs :
mitogen . debug . dump_to_logger ( secs = secs )
def _setup_simplejson ( self , responder ) :
"""
We support serving simplejson for Python 2.4 targets on Ansible 2.3 , at
least so the package ' s own CI Docker scripts can run without external
help , however newer versions of simplejson no longer support Python
2.4 . Therefore override any installed / loaded version with a
2.4 - compatible version we ship in the compat / directory .
"""
responder . whitelist_prefix ( ' simplejson ' )
# issue #536: must be at end of sys.path, in case existing newer
# version is already loaded.
compat_path = os . path . join ( os . path . dirname ( __file__ ) , ' compat ' )
sys . path . append ( compat_path )
for fullname , is_pkg , suffix in (
( u ' simplejson ' , True , ' __init__.py ' ) ,
( u ' simplejson.decoder ' , False , ' decoder.py ' ) ,
( u ' simplejson.encoder ' , False , ' encoder.py ' ) ,
( u ' simplejson.scanner ' , False , ' scanner.py ' ) ,
) :
path = os . path . join ( compat_path , ' simplejson ' , suffix )
fp = open ( path , ' rb ' )
try :
source = fp . read ( )
finally :
fp . close ( )
responder . add_source_override (
fullname = fullname ,
path = path ,
source = source ,
is_pkg = is_pkg ,
)
def _setup_responder ( self , responder ) :
"""
Configure : class : ` mitogen . master . ModuleResponder ` to only permit
@ -243,9 +278,7 @@ class MuxProcess(object):
"""
responder . whitelist_prefix ( ' ansible ' )
responder . whitelist_prefix ( ' ansible_mitogen ' )
responder . whitelist_prefix ( ' simplejson ' )
simplejson_path = os . path . join ( os . path . dirname ( __file__ ) , ' compat ' )
sys . path . insert ( 0 , simplejson_path )
self . _setup_simplejson ( responder )
# Ansible 2.3 is compatible with Python 2.4 targets, however
# ansible/__init__.py is not. Instead, executor/module_common.py writes