Skip to content

Commit 707a996

Browse files
author
Zach Moody
committed
Don't run twice when threading
Fixes #360
1 parent 30b813c commit 707a996

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

pynetbox/core/query.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -327,25 +327,26 @@ def get(self, add_params=None):
327327
self.concurrent_get(ret, page_size, page_offsets)
328328
for i in ret:
329329
yield i
330-
first_run = True
331-
for i in req["results"]:
332-
yield i
333-
while req["next"]:
334-
# Not worrying about making sure add_params kwargs is
335-
# passed in here because results from detail routes aren't
336-
# paginated, thus far.
337-
if first_run:
338-
req = self._make_call(
339-
add_params={
340-
"limit": self.limit or req["count"],
341-
"offset": len(req["results"]),
342-
}
343-
)
344-
else:
345-
req = self._make_call(url_override=req["next"])
346-
first_run = False
330+
else:
331+
first_run = True
347332
for i in req["results"]:
348333
yield i
334+
while req["next"]:
335+
# Not worrying about making sure add_params kwargs is
336+
# passed in here because results from detail routes aren't
337+
# paginated, thus far.
338+
if first_run:
339+
req = self._make_call(
340+
add_params={
341+
"limit": self.limit or req["count"],
342+
"offset": len(req["results"]),
343+
}
344+
)
345+
else:
346+
req = self._make_call(url_override=req["next"])
347+
first_run = False
348+
for i in req["results"]:
349+
yield i
349350
elif isinstance(req, list):
350351
self.count = len(req)
351352
for i in req:

0 commit comments

Comments
 (0)