Improving the main loop.

This commit is contained in:
Sergiotarxz 2024-05-23 17:19:36 +02:00
parent 998885b2a1
commit 6c44a9bb43
2 changed files with 10 additions and 1 deletions

View File

@ -26,7 +26,7 @@ has _ua => ( is => 'lazy', );
sub _build__ua {
my $ua = Mojo::UserAgent->new->with_roles('+Queued');
$ua->max_active(5);
$ua->max_active(20);
$ua->inactivity_timeout(60);
return $ua;
}

View File

@ -37,6 +37,15 @@ sub run ($self) {
}
}
sub run_recursive ($self) {
$self->_dispatch_updates.then(sub {
$self->run_recursive;
})->catch(sub ($err) {
warn $err;
$self->run_recursive;
});
}
sub _dispatch_updates ($self) {
my $updates_p = $self->_get_updates;
my $promise = Mojo::Promise->new;