tejado / pgoapi

Pokemon Go API lib
Other
1.4k stars 447 forks source link

Server throttle error message #185

Open scottxu2018 opened 7 years ago

scottxu2018 commented 7 years ago

I was trying to run pgoapi with error massage as below. How can I set a delay time?

Traceback (most recent call last): File "pokecli.py", line 139, in main() File "pokecli.py", line 135, in main response_dict = req.call() File "C:\Users\xxxxx\pgoapi\pgoapi\pgoapi.py", line 182, in call response = request.request(self._api_endpoint, self._req_method_list, self.g et_position()) File "C:\Users\xxxxx\pgoapi\pgoapi\rpc_api.py", line 118, in req uest raise ServerSideRequestThrottlingException("Request throttled by server... s low down man") pgoapi.exceptions.ServerSideRequestThrottlingException: Request throttled by ser ver... slow down man

Vigerus commented 7 years ago

import time and place time.sleep(1) before response_dict = req.call()

Btw. the lately added threadsafe modification:

req = api.create_request()

requests

time.sleep(1) response_dict = req.call()

doesn't work well with this throttling. I suggest a shared section instead:

import threading

api_call_lock = threading.Lock()

and then

with api_call_lock: req = api.create_request()

requests

time.sleep(1)
response_dict = req.call()    

if you're using many threads