(name)
return lock
Get or create the module lock for a given module name.

    Acquire/release internally the global import lock to protect
    _module_locks.
Get or create the module lock for a given module name.
Get or create the module lock for a given module name .
def _get_module_lock(name):
    """Get or create the module lock for a given module name.

    Acquire/release internally the global import lock to protect
    _module_locks."""

    _imp.acquire_lock()
    try:
        try:
            lock = _module_locks[name]()
        except KeyError:
            lock = None

        if lock is None:
            if _thread is None:
                lock = _DummyModuleLock(name)
            else:
                lock = _ModuleLock(name)

            def cb(ref, name=name):
                _imp.acquire_lock()
                try:
                    # bpo-31070: Check if another thread created a new lock
                    # after the previous lock was destroyed
                    # but before the weakref callback was called.
                    if _module_locks.get(name) is ref:
                        del _module_locks[name]
                finally:
                    _imp.release_lock()

            _module_locks[name] = _weakref.ref(lock, cb)
    finally:
        _imp.release_lock()

    return lock
def _get_module_lock ( name ) : _imp . acquire_lock ( ) try : try : lock = _module_locks [ name ] ( ) except KeyError : lock = None if lock is None : if _thread is None : lock = _DummyModuleLock ( name ) else : lock = _ModuleLock ( name ) def cb ( ref , name = name ) : _imp . acquire_lock ( ) try : # bpo-31070: Check if another thread created a new lock # after the previous lock was destroyed # but before the weakref callback was called. if _module_locks . get ( name ) is ref : del _module_locks [ name ] finally : _imp . release_lock ( ) _module_locks [ name ] = _weakref . ref ( lock , cb ) finally : _imp . release_lock ( ) return lock