python - How to avoid using intentional delay in back to back restful api calls to the same server? -


i sending http requests server www.xyz.com , server sends me key, need send request same server time using key in url well. problem that, if don't introduce sort of delay between 2 requests, second request shows same data first request. using python's urllib module. moment introduce time.sleep(5) gets alright? @ code below please

import urllib.request import xml.etree.elementtree et  compound_cid_url ='www.xyz.com' req = urllib.request.request(compound_cid_url) urllib.request.urlopen(req) response:     root = et.fromstring(response.read())     print(root) time.sleep(5) similar_cids_url = 'www.xyz.com/something/key' similar_cids_req = urllib.request.request(similar_cids_url) urllib.request.urlopen(similar_cids_req) cids_response:     root_cids = et.fromstring(cids_response.read())     print(root_cids) 

now if don't place time.sleep(5) here, root , root_cids have same xml data, of course server response first call, ideas?


Comments