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

[simulation] handle exception in heartbeat #1

Open
wants to merge 1 commit into
base: simulation
Choose a base branch
from

Conversation

memelyfe
Copy link

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

@leegao
Copy link
Owner

leegao commented Jul 17, 2016

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

[simulation] api request auto-retries. output lines up.
@memelyfe
Copy link
Author

amended. how's that?

RyanJarv referenced this pull request in RyanJarv/pokemongo-api-demo Jul 17, 2016
@MonsterMMORPG
Copy link

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

@g1zstar
Copy link

g1zstar commented Jul 17, 2016

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

@MonsterMMORPG
Copy link

it still gives error here the error message in infinite loop

errorrr

@MonsterMMORPG
Copy link

I am getting this error after a while

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

pull request : #1

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

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

@therealssj
Copy link

therealssj commented Jul 17, 2016

@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.

@MonsterMMORPG
Copy link

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

@therealssj
Copy link

@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

@MonsterMMORPG
Copy link

@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
Copy link

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
#1 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AD9Q4t_jRy3cx6050ygvRg3korqyELHUks5qWipMgaJpZM4JOHSd
.

@ArchdukeTim
Copy link

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

@MonsterMMORPG
Copy link

@Twinters007 same here

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

@MonsterMMORPG
Copy link

@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 :(

@ArchdukeTim
Copy link

ArchdukeTim commented Jul 18, 2016

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?

@MonsterMMORPG
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants