I have a reoccurring issue where when I run my scheduled task my python code keep grabbing twice as many records as it should. I did a print error log to see what was going on and it says it's breaking but still ends up populating twice as many as it should. When I just run it regularly it works fine and behaves as it is supposed to. I tried changing this: cd /home/samwins/zoho/analytics/witness_data/; python3.8 witness_automation.py but this jsut made it grab even more records than running it straight up. Why is this happening
Hotspot Status: online
DB Count: 420
Code Breaking
Code Finished
Grabbed Hotspot Statuses from API
As you can see it should have stopped at 420 records, but instead is stopping at 700 something records.
counter = counter - 9
print('Total Hotspots Deployed: ', counter)
db_count = -1
for (record_id, status, address, product_category) in hotspot_records:
if status == "Online" or status == "Offline":
yo = ""
if 'Radio' in product_category:
pass
else:
db_count = db_count + 1
headers = {'User-Agent': 'a1projects/1.0'}
url = "https://api.helium.io/v1/hotspots/" + address
response = request_function(url, headers)
response = response.json()
data = response['data']
status = data['status']['online']
print(f"Hotspot Status: {status}")
status = status.capitalize()
print("DB Count: ", db_count)
# print("Counter: ", counter)
if db_count == counter:
print('Code Breaking')
break
args = (dt.datetime.now(), record_id, address, status)
run_query(insert_hotspot_record, args)
zohoDB.close()
print('Code Finished')
[edit by admin: formatting]