pokemongo-api-demo icon indicating copy to clipboard operation
pokemongo-api-demo copied to clipboard

[simulation] handle exception in heartbeat

Open memelyfe opened this issue 8 years ago • 17 comments

fixes the script exiting whenever heartbeat has an issue (which seems to happen often)

memelyfe avatar Jul 16 '16 23:07 memelyfe

loveit

Can we actually do this retry on the api_req function? This way, we can get some sort of retry guarantee while authenticating a user. Just in case Niantic releases the game to another 26 countries tomorrow, we can still make sure that nothing breaks :P

leegao avatar Jul 17 '16 03:07 leegao

amended. how's that?

memelyfe avatar Jul 17 '16 04:07 memelyfe

Someone can please make a tutorial how can we locally merge the pull requests to use the latest version?

MonsterMMORPG avatar Jul 17 '16 09:07 MonsterMMORPG

Take your api_req, add while True: to the top of it, indent everything below by one tab.

g1zstar avatar Jul 17 '16 09:07 g1zstar

it still gives error here the error message in infinite loop

errorrr

MonsterMMORPG avatar Jul 17 '16 11:07 MonsterMMORPG

I am getting this error after a while

Using "[simulation] handle exception in heartbeat" pull request

pull request : https://github.com/leegao/pokemongo-api-demo/pull/1

my main file : http://pastebin.com/4fxJuYNv

error message : https://i.snag.gy/Hl9r8q.jpg

MonsterMMORPG avatar Jul 17 '16 12:07 MonsterMMORPG

@MonsterMMORPG the payload is empty so u need to put a check there. I have a different implementation but I do something like

 if not response.payload:
        return None

This is in the heartbeat process and I have put a while loop on heartbeat and if it returns None the request is repeated with a break.

therealssj avatar Jul 17 '16 12:07 therealssj

@therealssj can you show me where should i put in in this file? http://pastebin.com/4fxJuYNv

MonsterMMORPG avatar Jul 17 '16 12:07 MonsterMMORPG

@MonsterMMORPG it's not a single line but multiple changes.

Line 230:
payload = response.payload[0]
To: 
if not reponse.payload:
  return None

Line 290:
 h = heartbeat(api_endpoint, access_token, response)
To:
h = None
while h is None:
     h = heartbeat(api_endpoint, access_token, response)
     print("Heartbeat Error, Sleeping for 2 second..")
     time.sleep(2)

It's a dirty implementation but works for now

therealssj avatar Jul 17 '16 12:07 therealssj

@therealssj awesome ty. 1 more thing. can you show me how can i play a sound when an error occurred? i am trying to run infinite loop and i dont want to check it constantly :D

MonsterMMORPG avatar Jul 17 '16 13:07 MonsterMMORPG

@MonsterMMORPG http://stackoverflow.com/questions/4467240/play-simple-beep-with-python-without-external-library

therealssj avatar Jul 17 '16 13:07 therealssj

The issue is I don't have any idea how to detect global errors so I can play sound

On Jul 17, 2016 16:12, "Mehul" [email protected] wrote:

@MonsterMMORPG https://github.com/MonsterMMORPG http://stackoverflow.com/questions/4467240/play-simple-beep-with-python-without-external-library

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/leegao/pokemongo-api-demo/pull/1#issuecomment-233181351, or mute the thread https://github.com/notifications/unsubscribe-auth/AD9Q4t_jRy3cx6050ygvRg3korqyELHUks5qWipMgaJpZM4JOHSd .

MonsterMMORPG avatar Jul 17 '16 13:07 MonsterMMORPG

any idea why I keep getting a index out of range at line 271

ArchdukeTim avatar Jul 17 '16 15:07 ArchdukeTim

@Twinters007 same here

it is because the servers are screwed and errors are not handled properly

MonsterMMORPG avatar Jul 17 '16 16:07 MonsterMMORPG

@memelyfe can you check whether the searching algorithm can be improved or not? i am running 3 instances and nothing worthy appears in my city :(

MonsterMMORPG avatar Jul 17 '16 23:07 MonsterMMORPG

I think I just did.

https://github.com/leegao/pokemongo-api-demo/blob/simulation/main.py#L282

What I suspect is happening is the algorithm is supposed to go x steps, then start over, but in this line, it sets [original latitude] to [currently used latitude]. so when it resets, it doesn't actually go back to home. This combined with going only forward along the walk instead of forward and backward would explain why everything shifts upwards.

I also got rid of the walk = getNeighbors(), because the first walk already gets 20 steps (10+ and 10-), so I think finding neighbors each iteration isn't what we want.

UPDATE: So I think it has to do with S2 and Hillbert Curves, so I tried using just a grid of points, but it doesn't seem to work with the heartbeat and everything. Ideas?

ArchdukeTim avatar Jul 18 '16 03:07 ArchdukeTim

@Twinters007 so what changes do we need to make to fix? ty

MonsterMMORPG avatar Jul 18 '16 10:07 MonsterMMORPG