I have two large lists of same size. I am making subprocess calls with ith element of both lists as arguments:
for index in range(len(skuList)):
sku = skuList[index]
qty = qtyList[index]
cmd1 = 'php -f ReviseItem.php %s %s' % (sku,qty)
print cmd1
args1 = shlex.split(cmd1)
p=subprocess.Popen(args1)
p.wait()
I am actually making an API call in the ReviseItem
script. But, the API server is such that I can make a maximum of 15 requests and throttled for next 2 minutes. How can I modify my code to satisfy this. Is there a way to stop the execution for 2 minutes after 15 subprocesses are spawned?
EDIT: I am still getting throttled after waiting for 2 minutes after 15 request. It seems that I'm throttled until 15 requests are processed by the server, as mentioned here
and not after making the requests.
EDIT2: if I get throttled and the request does not get processed, I get the following message (among others) in the standard output:
<ErrorResponse xmlns="http://mws.amazonaws.com/doc/2009-01-01/">
<Error>
<Type></Type>
<Code>RequestThrottled</Code>
<Message>Request is throttled</Message>
</Error>
<RequestID>3ca74b8b-cdc2-47df-b48b-043eb5411cda</RequestID>
</ErrorResponse>
Also, I can make another API call to find out the request ID of the last processed request. Again, Request ID is in the standard output of the calls(both the original and this call) among other messages
RequestThrottled