human
Complete this python program:
def _make_request_id_aware_start_new_thread(base_start_new_thread):
assistant
#Here is the Python code you requested.

    """Returns a replacement for start_new_thread that inherits request id.
    Returns a function with an interface that matches thread.start_new_thread
    where the new thread inherits the request id of the current thread. The
    request id is used by the Remote API to associate API calls with the HTTP
    request that provoked them.
    Args:
    base_start_new_thread: The thread.start_new_thread function to call to
    create a new thread.
    Returns:
    A replacement for start_new_thread.
    """
    def _start_new_thread(target, args, kw=None):
        if (kw is None):
            kw = {}
        request_id = remote_api_stub.RemoteStub._GetRequestId()
        request = request_state.get_request_state(request_id)
        def _run():
            try:
                remote_api_stub.RemoteStub._SetRequestId(request_id)
                request.start_thread()
                target(*args, **kw)
            finally:
                request_environment.current_request.Clear()
                request.end_thread()
        return base_start_new_thread(_run, ())
    return _start_new_thread