File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -787,18 +787,17 @@ def find_distributions(self, context=Context()) -> Iterable[Distribution]:
787787 """
788788
789789
790- def _clear_lru_cache_after_fork ( func ):
791- """Wrap ``func`` with ``functools.lru_cache`` and clear it after ``fork``.
790+ def _clear_after_fork ( cached ):
791+ """Ensure ``func`` clears cached state after ``fork`` when supported .
792792
793- ``FastPath`` caches zip-backed ``pathlib.Path`` objects that keep a
793+ ``FastPath`` caches zip-backed ``pathlib.Path`` objects that retain a
794794 reference to the parent's open ``ZipFile`` handle. Re-using a cached
795795 instance in a forked child can therefore resurrect invalid file pointers
796796 and trigger ``BadZipFile``/``OSError`` failures (python/importlib_metadata#520).
797- Registering ``cache_clear`` with ``os.register_at_fork`` ensures every
798- process gets a pristine cache and opens its own archive handles .
797+ Registering ``cache_clear`` with ``os.register_at_fork`` keeps each process
798+ on its own cache .
799799 """
800800
801- cached = functools .lru_cache ()(func )
802801 register = getattr (os , 'register_at_fork' , None )
803802 if register is not None :
804803 register (after_in_child = cached .cache_clear )
@@ -821,7 +820,8 @@ class FastPath:
821820 True
822821 """
823822
824- @_clear_lru_cache_after_fork
823+ @_clear_after_fork
824+ @functools .lru_cache ()
825825 def __new__ (cls , root ):
826826 return super ().__new__ (cls )
827827
You can’t perform that action at this time.
0 commit comments