def tempdir_registry():
    # type: () -> Iterator[TempDirectoryTypeRegistry]
    """Provides a scoped global tempdir registry that can be used to dictate
    whether directories should be deleted.
    """
    global _tempdir_registry
    old_tempdir_registry = _tempdir_registry
    _tempdir_registry = TempDirectoryTypeRegistry()
    try:
        yield _tempdir_registry
    finally:
        _tempdir_registry = old_tempdir_registry
Provides a scoped global tempdir registry that can be used to dictate
    whether directories should be deleted.
    
product/gradle-plugin/src/main/python/pip/_internal/utils/temp_dir.py