This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use common::sense; | |
use DDP; | |
use Mojo::Promise; | |
use Mojo::IOLoop::Subprocess; | |
my $subprocess = Mojo::IOLoop::Subprocess->new; | |
$subprocess->run( | |
sub { | |
my $subprocess = shift; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use common::sense; | |
use DDP; | |
use Mojo::Promise; | |
use Mojo::IOLoop::Subprocess; | |
my $subprocess = Mojo::IOLoop::Subprocess->new; | |
$subprocess->run( | |
sub { | |
my $subprocess = shift; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use common::sense; | |
use DDP; | |
use Mojo::Promise; | |
use Mojo::IOLoop::Subprocess; | |
my $subprocess = Mojo::IOLoop::Subprocess->new; | |
$subprocess->run( | |
sub { | |
my $subprocess = shift; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package MojoX::InsistentPromise; | |
use strict; | |
use Carp; | |
my @retry_pos = (0, 0.5, 1, 3, 7, 13, 21, 34, 55, 60, 120); | |
$_ = $_ / 10000 for @retry_pos; # Test only! | |
use Scalar::Util 'weaken'; | |
sub new { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use Mojo::Promise; | |
use Mojo::UserAgent; | |
use DDP; | |
use Memory::Usage; | |
my $mu = Memory::Usage->new(); | |
my $ua = Mojo::UserAgent->new->inactivity_timeout(1); | |
my $max_fail_num = 100; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
perl lost-and-found/promises-retry-test.pl | |
time vsz ( diff) rss ( diff) shared ( diff) code ( diff) data ( diff) | |
0 116440 ( 116440) 39960 ( 39960) 7388 ( 7388) 2944 ( 2944) 32912 ( 32912) starting work | |
4 489688 ( 373248) 44448 ( 4488) 7388 ( 0) 2944 ( 0) 79120 ( 46208) Iteration 1000 | |
10 492144 ( 2456) 47088 ( 2640) 7388 ( 0) 2944 ( 0) 81576 ( 2456) Iteration 2000 | |
14 492144 ( 0) 47088 ( 0) 7388 ( 0) 2944 ( 0) 81576 ( 0) Iteration 3000 | |
17 492144 ( 0) 47088 ( 0) 7388 ( 0) 2944 ( 0) 81576 ( 0) Iteration 4000 | |
22 492144 ( 0) 47088 ( 0) 7388 ( 0) 2944 ( 0) 81576 ( 0) Iteration 5000 | |
26 492144 ( 0) 47088 ( 0) 7388 ( 0) 2944 ( 0) 81576 ( 0) Iteration 6000 | |
30 492144 ( 0) 47088 ( 0) 7388 ( 0) 2944 ( 0) 81576 ( 0) Iteration 7000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use Mojo::Promise; | |
use Mojo::UserAgent; | |
use DDP; | |
my $ua = Mojo::UserAgent->new->with_roles('+Queued')->inactivity_timeout(1); | |
my $max_fail_num = 100; | |
my $results_count = {}; | |
my @retry_pos = (0, 0.5, 1, 2, 4, 5, 10, 20, 25, 30, 40); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use Mojo::Promise; | |
use Mojo::UserAgent; | |
use DDP; | |
my $ua = Mojo::UserAgent->new->with_roles('+Queued')->inactivity_timeout(1); | |
my $max_fail_num = 100; | |
my $results_count = {}; | |
my @retry_pos = (0, 0.5, 1, 2, 4, 5, 10, 20, 25, 30, 40); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use Mojo::Promise; | |
use Mojo::UserAgent; | |
use DDP; | |
my $ua = Mojo::UserAgent->new->with_roles('+Queued')->inactivity_timeout(60); | |
my $max_fail_num = 100; | |
my $results_count = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub parse { | |
my $self = shift; | |
my $text = lc shift; | |
my $ret = shift; | |
$ret->{fixed} ||= 0; | |
return 'overflow_error' if $ret->{fixed} > 4; # nunca deve ocorrer, mas bugs sempre estao soltos. |