| 175 | self._event_to_subscription_mapping: Dict[str, str] = {} |
| 176 | |
| 177 | def _dispose(self, reason: Optional[str]) -> None: |
| 178 | # Clean up from parent and connection. |
| 179 | if self._parent: |
| 180 | del self._parent._objects[self._guid] |
| 181 | del self._connection._objects[self._guid] |
| 182 | self._was_collected = reason == "gc" |
| 183 | |
| 184 | # Dispose all children. |
| 185 | for object in list(self._objects.values()): |
| 186 | object._dispose(reason) |
| 187 | self._objects.clear() |
| 188 | |
| 189 | def _adopt(self, child: "ChannelOwner") -> None: |
| 190 | del cast("ChannelOwner", child._parent)._objects[child._guid] |