| 124 | return len(self._result_cache) > 0 |
| 125 | |
| 126 | def _manual_iter(self): |
| 127 | # If we're here, our cache isn't fully populated. |
| 128 | # For efficiency, fill the cache as we go if we run out of results. |
| 129 | # Also, this can't be part of the __iter__ method due to Python's rules |
| 130 | # about generator functions. |
| 131 | current_position = 0 |
| 132 | current_cache_max = 0 |
| 133 | |
| 134 | while True: |
| 135 | if len(self._result_cache) > 0: |
| 136 | try: |
| 137 | current_cache_max = self._result_cache.index(None) |
| 138 | except ValueError: |
| 139 | current_cache_max = len(self._result_cache) |
| 140 | |
| 141 | while current_position < current_cache_max: |
| 142 | yield self._result_cache[current_position] |
| 143 | current_position += 1 |
| 144 | |
| 145 | if self._cache_is_full(): |
| 146 | return |
| 147 | |
| 148 | # We've run out of results and haven't hit our limit. |
| 149 | # Fill more of the cache. |
| 150 | if not self._fill_cache( |
| 151 | current_position, current_position + ITERATOR_LOAD_PER_QUERY |
| 152 | ): |
| 153 | return |
| 154 | |
| 155 | def post_process_results(self, results): |
| 156 | to_cache = [] |