Add an externally created session to the pool. This is intended only for the cases when you want to add a session that was created outside of the pool. Otherwise, the pool will create new sessions automatically. Args: session: The session to add to the pool.
(self, session: Session)
| 161 | |
| 162 | @ensure_context |
| 163 | def add_session(self, session: Session) -> None: |
| 164 | """Add an externally created session to the pool. |
| 165 | |
| 166 | This is intended only for the cases when you want to add a session that was created outside of the pool. |
| 167 | Otherwise, the pool will create new sessions automatically. |
| 168 | |
| 169 | Args: |
| 170 | session: The session to add to the pool. |
| 171 | """ |
| 172 | state = self._state.current_value |
| 173 | |
| 174 | if session.id in state.sessions: |
| 175 | logger.warning(f'Session with ID {session.id} already exists in the pool.') |
| 176 | return |
| 177 | state.sessions[session.id] = session |
| 178 | |
| 179 | @ensure_context |
| 180 | async def get_session(self) -> Session: |
no outgoing calls