Skip to content

Commit

Permalink
Reduce number of times json() property is called, fixes PaloAltoNetwo…
Browse files Browse the repository at this point in the history
  • Loading branch information
sserrata committed Apr 3, 2020
1 parent 89c94d5 commit 8243ec5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pan_cortex_data_lake/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,22 +242,23 @@ def iter_job_results(
)
if not r.ok:
raise HTTPError("%s" % r.text)
if r.json()["state"] == "DONE":
page_cursor = r.json()["page"].get("pageCursor")
r_json = r.json()
if r_json["state"] == "DONE":
page_cursor = r_json["page"].get("pageCursor")
if page_cursor is not None:
params["pageCursor"] = page_cursor
yield r
else:
yield r
break
elif r.json()["state"] in ("RUNNING", "PENDING"):
elif r_json["state"] in ("RUNNING", "PENDING"):
yield r
time.sleep(1)
elif r.json()["state"] == "FAILED":
elif r_json["state"] == "FAILED":
yield r
break
else:
raise CortexError("Bad state: %s" % r.json()["state"])
raise CortexError("Bad state: %s" % r_json["state"])

def list_jobs(
self,
Expand Down

0 comments on commit 8243ec5

Please sign in to comment.