Skip to content

Commit 2b7a09f

Browse files
committed
Retrieve json directly during await, instead of retrieving text that needs to be converted to json.
1 parent 7391d80 commit 2b7a09f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

lightbeam/send.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ async def do_post(self, endpoint, file_name, data, client, line, hash):
165165
data=data,
166166
ssl=self.lightbeam.config["connection"]["verify_ssl"],
167167
headers=self.lightbeam.api.headers) as response:
168-
body = await response.text()
168+
body = await response.json()
169169
status = response.status
170170
if status!=401:
171171
# update status_counts (for every-second status update)
@@ -174,7 +174,7 @@ async def do_post(self, endpoint, file_name, data, client, line, hash):
174174

175175
# warn about errors
176176
if response.status not in [ 200, 201 ]:
177-
message = str(response.status) + ": " + util.linearize(json.loads(body).get("message"))
177+
message = str(response.status) + ": " + util.linearize(body.get("message"))
178178

179179
# update run metadata...
180180
failed_statuses_dict = self.metadata["resources"][endpoint].get("failed_statuses", {})

0 commit comments

Comments
 (0)