MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _IterationGuard

Class _IterationGuard

tools/python-3.11.9-amd64/Lib/_weakrefset.py:11–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9
10
11class _IterationGuard:
12 # This context manager registers itself in the current iterators of the
13 # weak container, such as to delay all removals until the context manager
14 # exits.
15 # This technique should be relatively thread-safe (since sets are).
16
17 def __init__(self, weakcontainer):
18 # Don't create cycles
19 self.weakcontainer = ref(weakcontainer)
20
21 def __enter__(self):
22 w = self.weakcontainer()
23 if w is not None:
24 w._iterating.add(self)
25 return self
26
27 def __exit__(self, e, t, b):
28 w = self.weakcontainer()
29 if w is not None:
30 s = w._iterating
31 s.remove(self)
32 if not s:
33 w._commit_removals()
34
35
36class WeakSet:

Callers 12

copyMethod · 0.90
__deepcopy__Method · 0.90
itemsMethod · 0.90
keysMethod · 0.90
itervaluerefsMethod · 0.90
valuesMethod · 0.90
copyMethod · 0.90
__deepcopy__Method · 0.90
itemsMethod · 0.90
keysMethod · 0.90
valuesMethod · 0.90
__iter__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected