I'm a Python novice. I've written a scheduled python 2.7 script for checking a web service URL for issues.
#The external system's vendor provides a public sample server that can be used for testing purposes:
#https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/MapServer/1/query?where=SUBMITDT%3CDATE%272018-05-11%27&f=pjson&returnCountOnly=true
try:
result = fetch_row_count(url)
if result == 0:
print "All records are synced. No need to do anything."
elif result is None:
#Comm Template CGGISWO_ERROR: "The Collector WO map service had an error when pinged by the CGGISSERVICE escalation."
# "Check for WOs that have not been synced to Maximo."
ctMboSet = mbo.getMboSet("$commtemp", "COMMTEMPLATE", "TEMPLATEID ='CGGISWO_ERROR'")
ctMbo = ctMboSet.getMbo(0)
ctMbo.sendMessage(mbo, mbo)
elif result > 0:
#Comm Template CGGISWO_NOSYNC: "There are Collector WOs that have not been synced to Maximo."
# "The WO COLLECTOR map service has records from previous days that need to be synced."
ctMboSet = mbo.getMboSet("$commtemp", "COMMTEMPLATE", "TEMPLATEID ='CGGISWO_NOSYNC'")
ctMbo = ctMboSet.getMbo(0)
ctMbo.sendMessage(mbo, mbo)
except:
#Comm Template CGGISWO_TIMEOUT: "The Collector WO map service timed-out when pinged by the CGGISSERVICE escalation."
# "Check for WOs that have not been synced to Maximo.""
ctMboSet = mbo.getMboSet("$commtemp", "COMMTEMPLATE", "TEMPLATEID ='CGGISWO_TIMEOUT'")
ctMbo = ctMboSet.getMbo(0)
ctMbo.sendMessage(mbo, mbo)
My question is about the scenario where the web service hangs and the script times-out.
I've tried to handle that scenario with except
. But I'm not sure how to how to test if that will actually work or not (if the web service hangs).
Is there a way I can ping a web service that is currently hanging -- to see if my script works or not? Is there such a thing as a public sample web service that is always hanging (on purpose)?