MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / _removed_from_collection

Function _removed_from_collection

lib/sqlalchemy/event/registry.py:142–162  ·  view source on GitHub ↗
(
    event_key: _EventKey[_ET], owner: RefCollection[_ET]
)

Source from the content-addressed store, hash-verified

140
141
142def _removed_from_collection(
143 event_key: _EventKey[_ET], owner: RefCollection[_ET]
144) -> None:
145 key = event_key._key
146
147 dispatch_reg = _key_to_collection[key]
148
149 listen_ref = weakref.ref(event_key._listen_fn)
150
151 owner_ref = owner.ref
152 dispatch_reg.pop(owner_ref, None)
153 if not dispatch_reg:
154 del _key_to_collection[key]
155
156 if owner_ref in _collection_to_key:
157 listener_to_key = _collection_to_key[owner_ref]
158 # see #12216 - this guards against a removal that already occurred
159 # here. however, I cannot come up with a test that shows any negative
160 # side effects occurring from this removal happening, even though an
161 # event key may still be referenced from a clsleveldispatch here
162 listener_to_key.pop(listen_ref, None)
163
164
165def _stored_in_collection_multi(

Callers 1

remove_from_listMethod · 0.85

Calls 1

popMethod · 0.45

Tested by

no test coverage detected