def _MakeStartNewThread(base_start_new_thread):
 def StartNewThread(target, args, kw=None):
  'A replacement for thread.start_new_thread.\n\n    A replacement for thread.start_new_thread that inherits RequestEnvironment\n    state from its creator and cleans up that state when it terminates.\n\n    Args:\n      See thread.start_new_thread.\n\n    Returns:\n      See thread.start_new_thread.\n    '
  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

def _MakeStartNewThread ( base_start_new_thread ) : def StartNewThread ( target , args , kw = None ) : 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 .