MCPcopy
hub / github.com/PokemonGoF/PokemonGo-Bot / call

Method call

pokemongo_bot/api_wrapper.py:210–274  ·  view source on GitHub ↗
(self, max_retry=15)

Source from the content-addressed store, hash-verified

208 return True
209
210 def call(self, max_retry=15):
211 request_callers = self._pop_request_callers()
212 if not self.can_call():
213 return False # currently this is never ran, exceptions are raised before
214
215 request_timestamp = None
216 api_req_method_list = self._req_method_list
217 result = None
218 try_cnt = 0
219 throttling_retry = 0
220 unexpected_response_retry = 0
221 while True:
222 request_timestamp = self.throttle_sleep()
223 # self._call internally clear this field, so save it
224 self._req_method_list = [req_method for req_method in api_req_method_list]
225 should_throttle_retry = False
226 should_unexpected_response_retry = False
227 hashing_offline = False
228
229 try:
230 result = self._call()
231 except ServerSideRequestThrottlingException:
232 should_throttle_retry = True
233 except HashingOfflineException:
234 hashing_offline = True
235 except UnexpectedResponseException:
236 should_unexpected_response_retry = True
237 except:
238 should_unexpected_response_retry = True
239
240 if hashing_offline:
241 self.logger.warning('Hashing server issue, retrying in 5 Secs...')
242 sleep(5)
243 continue
244
245 if should_throttle_retry:
246 throttling_retry += 1
247 if throttling_retry >= max_retry:
248 raise ServerSideRequestThrottlingException('Server throttled too many times')
249 sleep(1) # huge sleep ?
250 continue # skip response checking
251
252 if should_unexpected_response_retry:
253 unexpected_response_retry += 1
254 if unexpected_response_retry >= 5:
255 self.logger.warning(
256 'Server is not responding correctly to our requests. Waiting for 30 seconds to reconnect.')
257 sleep(30)
258 else:
259 sleep(2)
260 continue
261
262 if not self.is_response_valid(result, request_callers):
263 try_cnt += 1
264 if try_cnt > 3:
265 self.logger.warning(
266 'Server seems to be busy or offline - try again - {}/{}'.format(try_cnt, max_retry))
267 if try_cnt >= max_retry:

Callers 15

sFunction · 0.80
browserMqtt.jsFile · 0.80
MqttClientFunction · 0.80
BufferListFunction · 0.80
DuplexFunction · 0.80
PassThroughFunction · 0.80
ReadableFunction · 0.80
TransformFunction · 0.80
WritableFunction · 0.80
objectToStringFunction · 0.80
DuplexifyFunction · 0.80
DestroyableTransformFunction · 0.80

Calls 6

_pop_request_callersMethod · 0.95
can_callMethod · 0.95
throttle_sleepMethod · 0.95
_callMethod · 0.95
is_response_validMethod · 0.95
sleepFunction · 0.85