From 8426dc6dfbd1442d98ca0749c508504de914e5d9 Mon Sep 17 00:00:00 2001 From: Sergiotarxz Date: Fri, 24 May 2024 08:38:59 +0200 Subject: [PATCH] Adding lock to recurring. --- lib/TgMagicPdf/Telegram.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/TgMagicPdf/Telegram.pm b/lib/TgMagicPdf/Telegram.pm index 1f04c7d..5f00f9f 100644 --- a/lib/TgMagicPdf/Telegram.pm +++ b/lib/TgMagicPdf/Telegram.pm @@ -39,9 +39,14 @@ sub run ($self) { } sub _dispatch_updates ($self) { + my $in_process = 0; Mojo::IOLoop->recurring( - 0.5, + 0.1, sub { + if ($in_process) { + return; + } + $in_process = 1; if ( $self->_used_cores >= $self->_cores ) { return; } @@ -96,6 +101,7 @@ sub _dispatch_updates ($self) { ); say $i; } + $in_process = 0; } ); }