| 146 | |
| 147 | class ChannelOwner(AsyncIOEventEmitter): |
| 148 | def __init__( |
| 149 | self, |
| 150 | parent: Union["ChannelOwner", "Connection"], |
| 151 | type: str, |
| 152 | guid: str, |
| 153 | initializer: Dict, |
| 154 | ) -> None: |
| 155 | super().__init__(loop=parent._loop) |
| 156 | self._loop: asyncio.AbstractEventLoop = parent._loop |
| 157 | self._dispatcher_fiber: Any = parent._dispatcher_fiber |
| 158 | self._type = type |
| 159 | self._guid: str = guid |
| 160 | self._connection: Connection = ( |
| 161 | parent._connection if isinstance(parent, ChannelOwner) else parent |
| 162 | ) |
| 163 | self._parent: Optional[ChannelOwner] = ( |
| 164 | parent if isinstance(parent, ChannelOwner) else None |
| 165 | ) |
| 166 | self._objects: Dict[str, "ChannelOwner"] = {} |
| 167 | self._channel: Channel = Channel(self._connection, self) |
| 168 | self._initializer = initializer |
| 169 | self._was_collected = False |
| 170 | |
| 171 | self._connection._objects[guid] = self |
| 172 | if self._parent: |
| 173 | self._parent._objects[guid] = self |
| 174 | |
| 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. |