GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Converting Logging client->list_entries to iterator. by dhermes · Pull Request #2636 · googleapis/google-cloud-python Conversation
|
|
iirc logging has some very strange behavior with listing entries, I think @waprin is pretty familiar with it. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Yes specifically it uses the page tokens as a progress indicator, not just as a means of breaking results into pages. This means you can get 0 results on first page, but then 10 results on the next page, so you really always want to check the page token. This is especially true for slower queries, which are most of them without an index e.g. logName= . |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@tseaver @daspecster PTAL |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@waprin So what are the implications for using an Iterator? It'll just take a long time consuming empty pages until the results are available? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@dhermes yeah, if anything I'm thinking this is a very good change because with the iterator people are less likely to get no results on the first page and think there are no results. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@waprin is there a possibility the iterator will never finish? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| method='GET', path=self.path, | ||
| query_params=self._get_query_params()) | ||
| params = self._get_query_params() | ||
| if self._HTTP_METHOD == 'GET': |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| 'data': {}, | ||
| }) | ||
|
|
||
| def test__get_next_page_bad_http_method(self): |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| >>> client = logging.Client() | ||
| >>> entries, token = client.list_entries() # API call | ||
| >>> for entry in entries: | ||
| >>> for entry in client.list_entries(): # API call(s) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| """Detect correct entry type from resource and instantiate. | ||
|
|
||
| :type resource: dict | ||
| :param resource: one entry resource from API response |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| elif 'protoPayload' in resource: | ||
| return ProtobufEntry.from_api_repr(resource, client, loggers) | ||
|
|
||
| raise ValueError('Cannot parse log entry resource') |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| entry_pb = LogEntry(log_name=self.LOG_NAME, | ||
| timestamp = datetime.datetime.utcnow().replace(tzinfo=UTC) | ||
| timestamp_pb = _datetime_to_pb_timestamp(timestamp) | ||
| entry_pb = LogEntry(log_name=self.LOG_PATH, |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| return self.client.connection.api_request( | ||
| method=self._HTTP_METHOD, | ||
| path=self.path, | ||
| data=params) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@jonparrott can't think of a way |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@tseaver LGTY to merge? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
As discussed with @daspecster, going to make the docstring updates in a follow-up PR |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Converting Logging client->list_entries to iterator.
Converting Logging client->list_entries to iterator.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.