Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added retries for get_inventory if no GET_INVENTORY in response. #1519

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,16 @@ def use_lucky_egg(self):

def get_inventory(self):
if self.latest_inventory is None:
self.api.get_inventory()
response = self.api.call()
retries = 0
while True:
time.sleep((2**retries * 100) / 1000.0)
self.api.get_inventory()
response = self.api.call()
try:
get_inventory = response['responses']['GET_INVENTORY']
break
except:
retries += 1
self.latest_inventory = response
return self.latest_inventory

Expand Down
3 changes: 1 addition & 2 deletions pokemongo_bot/cell_workers/pokemon_transfer_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ def work(self):

def _release_pokemon_get_groups(self):
pokemon_groups = {}
self.api.get_player().get_inventory()
inventory_req = self.api.call()
inventory_req = self.bot.get_inventory()

if inventory_req.get('responses', False) is False:
return pokemon_groups
Expand Down