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

Rate Limit checking... lieing? #371

Closed
RedactedProfile opened this issue Jul 18, 2016 · 8 comments
Closed

Rate Limit checking... lieing? #371

RedactedProfile opened this issue Jul 18, 2016 · 8 comments

Comments

@RedactedProfile
Copy link

TBH im not sure which layer the issue exists in

I have a loop that continuously looks for new mentions with the GetMentions function.

But before I call the functiom, I use the CheckRateLimit for the remaining of the call.

It will come back with 15 remaining, but then i call the function and itll throw a Rate Limit Exceeded TwitterError exception.

When I make the calls manually myself, and then run the script ill see RateLimit Remaining be 14. So thats working.

For the record, PostUpdate did this too, on the first time ever using it.

Is something in the lib cracking out?

@RedactedProfile
Copy link
Author

I... dont know how to edit my post on mobile, so apologies for the reply

I forgot to mention that my loop runs on intervals of 1 minute. But it doesnt matter, because this starts happening pretty much right away. Sometimes itll go through 4 or 6 succesafully so long as theres no data in it (empty) but the moment theres a Mention available it starts throw Rate Limit Exceeded errors, or throw them even wgen empty perhaps after two iterations

@jeremylow
Copy link
Collaborator

Any chance I could see the code you're running? That's definitely not supposed to happen & if you're sleeping (or whatever) for one minute, then you should never get a rate limit error since you'll always be abiding by the 15/15 call/window limits.

@RedactedProfile
Copy link
Author

See, what your saying is exactly what im expecting to happen. I will
provide the code thats running it, but itll be a few more hours at least as
im nowhere near my computer.

I knew I should have comitted it to SOMETHING lol

On Jul 18, 2016 7:03 PM, "Jeremy Low" notifications@github.com wrote:

Any chance I could see the code you're running? That's definitely not
supposed to happen & if you're sleeping (or whatever) for one minute, then
you should never get a rate limit error since you'll always be abiding by
the 15/15 call/window limits.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#371 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA_eJ2ER9UeZ-P8VGMGn81GLRJ6if1w3ks5qXDBugaJpZM4JOcAM
.

@RedactedProfile
Copy link
Author

Hmm I've been testing the script again after 24 hours of not running it and I no longer seem to be running into the rate limit issue no matter how hard I try to trigger it within my current parameters.

Im not completely convinced it's resolved quite yet though, ill post again if I see the problem happen

@jeremylow
Copy link
Collaborator

jeremylow commented Jul 19, 2016

Weird, but I'm glad it's working. One thing I noticed in the code sample you provided:

You're checking for replylimit.remaining once per iteration of the while loop and then replying to all mentions found in the outer loop within a subloop. What's probably happening is that you have, say, 1 reply remaining when you check for mentions in the outer loop. Then you get back, say, 5 mentions in the api.GetMentions() call. You then enter the for loop attempting to reply to the 5 new mentions, but you've only got one allowed reply left, resulting in the rate limit error when you try to reply to the second mention (i.e., the 2nd iteration of the for loop)

You could fix this by checking the reply limit within the for loop, but for your use case, I'd suggest using the streaming endpoints. I wrote up a post a little while ago on using them to track a hashtag, but it's basically the same principle for replying to tweets:

https://iseverythingstilltheworst.com/blog/2016/05/28/capturing_twitter_streams/

Let me know if this is OK to close.

@RedactedProfile
Copy link
Author

I will check that out thank you :)

and you are correct, this chunk is far from perfect and riddled with edge
cases like that. However the call that kept failing was the GetMentions
which the ratelimit remaining would report as having 15 remaining.

I dont know if twitter was just having an off day or something but ya it
doesnt seem to be an issue any longer

Again ill check out the streaming docs, does sound closer to what i think
im trying to arrive at here haha

cheers!

On Jul 19, 2016 2:52 AM, "Jeremy Low" notifications@github.com wrote:

Weird, but I'm glad it's working. One thing I noticed in the code sample
you provided:

You're checking for replylimit.remaining once per iteration of the while
loop and then replying to all mentions found in the outer loop within a
subloop. What's probably happening is that you have, say, 1 reply remaining
when you check for mentions in the outer loop. Then you get back, say, 5
mentions in the api.GetMentions() call. You then enter the for loop
attempting to reply to the 5 new mentions, but you've only got one allowed
reply left, resulting in the rate limit error when you try to reply to the
second mention (i.e., the 2nd iteration of the for loop)

You could fix this by checking the reply limit within the for loop, but
for your use case, I'd suggest using the streaming endpoints. I wrote up a
post a little while ago on using them to track a hashtag, but it's
basically the same principle for replying to tweets:

https://iseverythingstilltheworst.com/blog/2016/05/28/capturing_twitter_streams/

Let me know if this is OK to close.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#371 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA_eJ2SaLMY8qRm4JEWpovH0nfOeSq5Tks5qXJ5TgaJpZM4JOcAM
.

@jeremylow
Copy link
Collaborator

Yeah that happens sometimes. Check out issue #350 for the last time Twitter kept reporting conflicting information. I'll close this issue in a week unless something changes.

@RedactedProfile
Copy link
Author

I appreciate it, thank you so much :)

On Jul 19, 2016 8:25 AM, "Jeremy Low" notifications@github.com wrote:

Yeah that happens sometimes. Check out issue #350
#350 for the last time
Twitter kept reporting conflicting information. I'll close this issue in a
week unless something changes.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#371 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA_eJ9URoIEFzx0-KeU0BKYe9pVx13nfks5qXOxsgaJpZM4JOcAM
.

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

No branches or pull requests

2 participants