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

Method _get_random_session

src/crawlee/sessions/_session_pool.py:243–248  ·  view source on GitHub ↗

Get a random session from the pool.

(self)

Source from the content-addressed store, hash-verified

241 await self._create_new_session()
242
243 def _get_random_session(self) -> Session:
244 """Get a random session from the pool."""
245 state = self._state.current_value
246 if not state.sessions:
247 raise ValueError('No sessions available in the pool.')
248 return random.choice(list(state.sessions.values()))
249
250 def _remove_retired_sessions(self) -> None:
251 """Remove all sessions from the pool that are no longer usable."""

Callers 1

get_sessionMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected