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

Method purge

src/crawlee/storages/_request_queue.py:153–175  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

151
152 @override
153 async def purge(self) -> None:
154 try:
155 await self._client.purge()
156 except NotImplementedError:
157 client_name = type(self._client).__name__
158 if self._name is not None:
159 logger.warning(
160 f'Storage client "{client_name}" does not support purging the request queue. '
161 f'Skipping purge for named queue "{self._name}" to avoid destroying persistent data; '
162 'the queue contents are left intact.'
163 )
164 return
165 logger.warning(
166 f'Storage client "{client_name}" does not support purging the request queue. '
167 'Falling back to dropping and recreating the unnamed queue; the request queue ID may change.'
168 )
169 await self.drop()
170 # Override `purge_on_start` so the storage client does not try to purge the freshly recreated
171 # (and necessarily empty) queue and re-raise the same `NotImplementedError`.
172 recreate_config = service_locator.get_configuration().model_copy(update={'purge_on_start': False})
173 new_rq = await RequestQueue.open(configuration=recreate_config)
174 self._client = new_rq._client # noqa: SLF001
175 self._id = new_rq._id # noqa: SLF001
176
177 @override
178 async def add_request(

Callers

nothing calls this directly

Calls 3

dropMethod · 0.95
get_configurationMethod · 0.80
openMethod · 0.45

Tested by

no test coverage detected