diff --git a/lib/TgMagicPdf/PdfBuilder.pm b/lib/TgMagicPdf/PdfBuilder.pm index c3abcfa..b135f5e 100644 --- a/lib/TgMagicPdf/PdfBuilder.pm +++ b/lib/TgMagicPdf/PdfBuilder.pm @@ -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; } diff --git a/lib/TgMagicPdf/Telegram.pm b/lib/TgMagicPdf/Telegram.pm index 7394f0c..7832545 100644 --- a/lib/TgMagicPdf/Telegram.pm +++ b/lib/TgMagicPdf/Telegram.pm @@ -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;