Twitte...OnError(3pm)
π Twitter::API::Trait::RetryOnError π
okay bestie, so this is Twitter::API::Trait::RetryOnError, and it's literally the trait that catches your API calls when they faceplant and goes "no babe, we're trying that again" π
VERSION: version 1.0006 β¨
πΈ SYNOPSIS πΈ
use Twitter::API;
my $client = Twitter::API->new_with_options(
traits => [ qw/ApiMethods RetryOnError/ ],
%other_optons
);
my $statuses = $client->home_timeline;
π¦ DESCRIPTION π¦
So when you apply this trait, Twitter::API becomes that friend who just does not give up. Any API call that comes back with an HTTP status code of 500 or greater? It gets automatically retried, no questions asked. π«Ά
And honestly those errors are usually giving "temporary problem" energy β could be on Twitter's end, could be locally, could be literally anywhere in between. Nobody knows, but it's almost never permanent. π
By default it retries up to 5 times. The initial retry waits 250ms first. Every retry after that doubles the delay time until it hits the maximum delay (default: 4 seconds). Then it's done.
And when does it finally give up? Twitter::API throws a Twitter::API::Error exception when it gets a permanent error (that's an HTTP status code below 500, for the record), or when it's hit the maximum number of retries. That's it, that's the whole vibe check. π
For non-blocking applications, set a suitable retry_delay_code callback, because obviously you can't just sit there sleeping like a normie. β¨ Bonus: this attribute can also be used to provide retry logging, so you can watch the whole thing happen in real time. π
β¨ ATTRIBUTES β¨
π initial_retry_delay
How long to chill before the very first retry. It's specified in fractional seconds. Default: 0.25 (that's 250ms, bestie). π
π max_retry_delay
The absolute maximum delay between retries, also specified in fractional seconds. Default: 4.0. π
π retry_delay_multiplier
After that initial delay, the delay time gets multiplied by this factor so it progressively backs off, giving the transient condition more room to sort itself out. self-care but for network requests β¨ However β and this is important β the delay never exceeds max_retry_delay. Default: 2.0. π
π max_retries
The maximum number of times to retry on error. Default: 5. That's five whole second chances, queen. π
π retry_delay_code
A coderef, called to actually implement the delay. It takes a single parameter: the number of seconds to delay. E.g., 0.25. The default implementation is simply this little icon:
sub { Time::HiRes::sleep(shift) }
π AUTHOR π
Marc Mims <marc@questright.com>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2015-2021 by Marc Mims.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
okay that's the whole page, no cap. π
and that's a wrap, bestie β this doc came to you courtesy of perl v5.32.1, dated 2021-09-11, and it's giving absolute manual-page royalty. slay, go retry some API calls responsibly π¦π
β¨
π¦ where this page comes from
- debian bookworm: libtwitter-api-perl 1.0006-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libtwitter-api-perl 1.0006-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libtwitter-api-perl 1.0006-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtwitter-api-perl 1.0006-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtwitter-api-perl 1.0006-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtwitter-api-perl 1.0006-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms