MCPcopy Index your code
hub / github.com/python/cpython / find_spec

Method find_spec

Lib/test/test_importlib/test_threaded_import.py:73–82  ·  view source on GitHub ↗
(self, name, path=None, target=None)

Source from the content-addressed store, hash-verified

71 self.lock = threading.Lock()
72
73 def find_spec(self, name, path=None, target=None):
74 # Simulate some thread-unsafe behaviour. If calls to find_spec()
75 # are properly serialized, `x` will end up the same as `numcalls`.
76 # Otherwise not.
77 assert imp.lock_held()
78 with self.lock:
79 self.numcalls += 1
80 x = self.x
81 time.sleep(0.01)
82 self.x = x + 1
83
84class FlushingFinder:
85 """A dummy finder which flushes sys.path_importer_cache when it gets

Callers 1

path_hookMethod · 0.45

Calls 1

sleepMethod · 0.45

Tested by

no test coverage detected