Client query status

Has there any better way to capture clientquery status when its done .
I have to put the sleep for 2 or 3min to get the query to be finish. the number of servers in the group can be varies from 200-600 per group.

bigfix_URL_client_query=“https://abc:52311/api/clientquery

req_bes_splunkfwd_log=requests.post(bigfix_URL_client_query,verify=False,auth=(bigfix_username,bigfix_pwd),data=xml_query)

tree2 = ET.fromstring(req_bes_splunkfwd_log.text)
query_ID=“”
for fixlet in tree2.findall(‘.//ClientQuery’):
query_ID=fixlet.find(“ID”).text

bigfix_URL_client_query_res=“https://abc:52311/api/clientqueryresults
bigfix_URL_query_res=bigfix_URL_client_query_res+“/”+query_ID
print("Sleeping for "+str(query_sleep_time)+“sec to let the LOG Query to finish:” )

time.sleep(query_sleep_time) ---->. sleep for 120sec

I don’t think so; one option would be to sleep for a shorter period, then retrieve results, check the number of them, and see if that matches the number you expect. For example poll every 30 seconds until you have full results, up to a max of a few minutes and then use what you have.

That’s similar to how the Query app in WebUI behaves, updating the results pane when new results report in.

That can doable but function can goes into the inifinite loop if the server count don’t match. Some time server don’t respond to the query for any reason.