File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,7 @@ def __init__(
119
119
target_objects_class .get_endpoint (),
120
120
)
121
121
self ._queue = []
122
+ self ._count = 0
122
123
self ._finished_iteration = False
123
124
self ._total_count = None
124
125
self ._include_summary = include_summary
@@ -133,12 +134,14 @@ def __iter__(self):
133
134
return self
134
135
135
136
def __next__ (self ):
137
+ self ._count += 1
136
138
# Load next page at end.
139
+ # If the queue counter equals the length of the queue and
137
140
# If load_next_page returns False, raise StopIteration exception
138
- if not self ._queue and not self .load_next_page ():
141
+ if ( self . _count == len ( self ._queue ) and not self .load_next_page () ):
139
142
raise StopIteration ()
140
143
141
- return self ._queue . pop ( 0 )
144
+ return self ._queue [ self . _count - 1 ]
142
145
143
146
# Python 2 compatibility.
144
147
next = __next__
@@ -187,6 +190,8 @@ def load_next_page(self):
187
190
self ._total_count = response ['summary' ]['total_count' ]
188
191
189
192
self ._queue = self .build_objects_from_response (response )
193
+ self ._count = 0
194
+
190
195
return len (self ._queue ) > 0
191
196
192
197
def build_objects_from_response (self , response ):
You can’t perform that action at this time.
0 commit comments