def _MakeStartNewThread(base_start_new_thread):

  def StartNewThread(target, args, kw=None):
    """A replacement for thread.start_new_thread.

    A replacement for thread.start_new_thread that inherits RequestEnvironment
    state from its creator and cleans up that state when it terminates.

    Args:
      See thread.start_new_thread.

    Returns:
      See thread.start_new_thread.
    """
    if kw is None:
      kw = {}
    cloner = request_environment.current_request.CloneRequestEnvironment()

    def Run():
      try:
        cloner()
        target(*args, **kw)
      finally:
        request_environment.current_request.Clear()
    return base_start_new_thread(Run, ())
  return StartNewThread
Returns a replacement for start_new_thread that inherits environment.
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/runtime/runtime.py/_MakeStartNewThread