Skip to content

Commit

Permalink
Fixes #1
Browse files Browse the repository at this point in the history
Read the response buffer directly, one line at a time, instead of iterating on response.text.
  • Loading branch information
psitem committed Apr 5, 2024
1 parent d673e40 commit afa6d7f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion code/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,12 @@ def action_Up():
resptxt = response.text
response.close()

for line in io.StringIO(resptxt):
while(response._received_length > 0):
## HELP monitor_status Monitor Status (1 = UP, 0= DOWN, 2= PENDING, 3= MAINTENANCE)
## monitor_status{monitor_name="name",monitor_type="http",monitor_url="http://mynameisurl",monitor_hostname="null",monitor_port="null"} 1
linebytes = response._readto(b"\n")
line = linebytes.decode()

res = reobj.match(line)
if ( res ):
if ( res.group(1) == '0' ):
Expand Down Expand Up @@ -361,6 +364,8 @@ def action_Up():
response = None
requests = None

line = None
linebytes = None
resptxt = None
response = None
requests = None
Expand Down

0 comments on commit afa6d7f

Please sign in to comment.