def save_request(self, request: Request) -> None: """Save a request to storage. Args: request: The request to save. """ request.id = str(uuid.uuid4()) with self._lock: if self._maxsize > 0: while len(self._requests) >= self._maxsize: self._requests.popitem(last=False) self._requests[request.id] = { 'request': request, }
def save_request(self, request: Request) -> None: """Save a request to storage. Args: request: The request to save. """ request_id = str(uuid.uuid4()) request_dir = self._get_request_dir(request_id) os.mkdir(request_dir) request.id = request_id self._save(request, request_dir, 'request') with self._lock: self._index.append( _IndexedRequest(id=request_id, url=request.url, has_response=False))