def METHOD_NAME():
    import attach_script
    import sys
    import time
    assert 'threading' not in sys.modules
    try:
        import thread
    except ImportError:
        import _thread as thread
    lock = thread.allocate_lock()
    lock2 = thread.allocate_lock()
    def method():
        lock2.acquire()
        import threading  # Note: imported on wrong thread
        assert threading.current_thread().ident == thread.get_ident()
        assert threading.current_thread() is attach_script.get_main_thread_instance(threading)
        attach_script.fix_main_thread_id()
        assert threading.current_thread().ident == thread.get_ident()
        assert threading.current_thread() is not attach_script.get_main_thread_instance(threading)
        with lock:
            pass  # Will only finish when lock is released.
    with lock:
        thread.start_new_thread(method, ())
        while not lock2.locked():
            time.sleep(.1)
        wait_for_condition(lambda: len(sys._current_frames()) == 2)
        main_thread_id, log_msg = attach_script.get_main_thread_id(None)
        assert main_thread_id == thread.get_ident(), 'Found: %s, Expected: %s' % (main_thread_id, thread.get_ident())
        assert not log_msg
        assert 'threading' in sys.modules
        import threading
        assert threading.current_thread().ident == main_thread_id
    wait_for_condition(lambda: len(sys._current_frames()) == 1)