def content_locate(self, account=None, reference=None, path=None, cid=None, content=None, version=None, properties=True, params=None, **kwargs): """ Get a description of the content along with the list of its chunks. :param cid: container id that can be used in place of `account` and `reference` :type cid: hexadecimal `str` :param content: content id that can be used in place of `path` :type content: hexadecimal `str` :param properties: should the request return object properties along with content description :type properties: `bool` :returns: a tuple with content metadata `dict` as first element and chunk `list` as second element """ content_meta, chunks = get_cached_object_metadata( account=account, reference=reference, path=path, cid=cid, version=version, properties=properties, **kwargs) if content_meta is not None and chunks is not None: # Refresh asynchronously so as not to slow down the current request eventlet.spawn_n(self._maybe_refresh_rawx_scores, **kwargs) for chunk in chunks: chunk['score'] = self.rawx_scores.get( chunk['url'].split('/')[2], 0) return content_meta, chunks uri = self._make_uri('content/locate') params['properties'] = properties try: resp, chunks = self._direct_request( 'GET', uri, params=params, **kwargs) content_meta = extract_content_headers_meta(resp.headers) except exceptions.OioNetworkException as exc: # TODO(FVE): this special behavior can be removed when # the 'content/locate' protocol is changed to include # object properties in the response body instead of headers. if properties and 'got more than ' in str(exc): params['properties'] = False _resp, chunks = self._direct_request( 'GET', uri, params=params, **kwargs) content_meta = self.content_get_properties( account, reference, path, cid=cid, content=content, version=version, **kwargs) else: raise set_cached_object_metadata( content_meta, chunks, account=account, reference=reference, path=path, cid=cid, version=version, properties=properties, **kwargs) return content_meta, chunks
def run(self): """ Start processing all found items. """ if self.dispatcher is None: raise ValueError('No dispatcher') eventlet.spawn_n(self._load_total_expected_items) # spawn one worker for the retry queue eventlet.spawn_n(self._read_retry_queue) for task_res in self.dispatcher.run(): yield task_res # block until the retry queue is empty if self.retry_queue: self.retry_queue.join()