code: def _patch_awx_callback():
      
      # AWX uses sitecustomize.py to force-load this package. If it exists, we're
      # running under AWX.
      try:
          from awx_display_callback.events import EventContext
          from awx_display_callback.events import event_context
      except ImportError:
          return
  
      if hasattr(EventContext(), '_local'):
          # Patched version.
          return
  
      def patch_add_local(self, **kwargs):
          tls = vars(self._local)
          ctx = tls.setdefault('_ctx', {})
          ctx.update(kwargs)
  
      EventContext._local = threading.local()
      EventContext.add_local = patch_add_local
docs: issue #400: AWX loads a display callback that suffers from thread-safety
      issues. Detect the presence of older AWX versions and patch the bug.