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

Check for rate limiting while fetching posts #7

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions tumblr-importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,10 @@ function fetch_posts($url, $start=0, $count = 50, $email = null, $password = nul
switch ( $response->meta->status ) {
case 200: // OK
break;
case 420: // rate limited
case 429: // rate limited
// make this chill for a minute
return false;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at the calling side(s), returning false seems to make it think it just needs to wait for later? it's hard for me to understand how this is meant to work, and it's definitely not resilient for this kind of event. looks like it'll keep while looping and getting a 429 Limit Exceeded, but maybe at least now it won't fail outright and stop trying.

default:
$_error = sprintf( __( 'Tumblr replied with an error: %s', 'tumblr-importer' ), $response->meta->msg );
do_action( 'tumblr_importer_handle_error', 'response_' . $response->meta->status );
Expand Down