MCPcopy Create free account
hub / github.com/apify/crawlee-python / add_session

Method add_session

src/crawlee/sessions/_session_pool.py:163–177  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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:

Callers 4

test_add_sessionFunction · 0.80

Calls

no outgoing calls

Tested by 4

test_add_sessionFunction · 0.64