From 5a29eb09600f5e6b7b2f9b869178d3c3781184d0 Mon Sep 17 00:00:00 2001 From: birdi Date: Thu, 15 Aug 2019 01:37:55 +0300 Subject: [PATCH] Add relax argument in executor.start_polling --- aiogram/utils/executor.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/aiogram/utils/executor.py b/aiogram/utils/executor.py index 854facae..33f80684 100644 --- a/aiogram/utils/executor.py +++ b/aiogram/utils/executor.py @@ -23,7 +23,7 @@ def _setup_callbacks(executor: 'Executor', on_startup=None, on_shutdown=None): def start_polling(dispatcher, *, loop=None, skip_updates=False, reset_webhook=True, - on_startup=None, on_shutdown=None, timeout=20, fast=True): + on_startup=None, on_shutdown=None, timeout=20, relax=0.1, fast=True): """ Start bot in long-polling mode @@ -38,7 +38,7 @@ def start_polling(dispatcher, *, loop=None, skip_updates=False, reset_webhook=Tr executor = Executor(dispatcher, skip_updates=skip_updates, loop=loop) _setup_callbacks(executor, on_startup, on_shutdown) - executor.start_polling(reset_webhook=reset_webhook, timeout=timeout, fast=fast) + executor.start_polling(reset_webhook=reset_webhook, timeout=timeout, relax=relax, fast=fast) def set_webhook(dispatcher: Dispatcher, webhook_path: str, *, loop: Optional[asyncio.AbstractEventLoop] = None, @@ -291,7 +291,7 @@ class Executor: self.set_webhook(webhook_path=webhook_path, request_handler=request_handler, route_name=route_name) self.run_app(**kwargs) - def start_polling(self, reset_webhook=None, timeout=20, fast=True): + def start_polling(self, reset_webhook=None, timeout=20, relax=0.1, fast=True): """ Start bot in long-polling mode @@ -303,7 +303,8 @@ class Executor: try: loop.run_until_complete(self._startup_polling()) - loop.create_task(self.dispatcher.start_polling(reset_webhook=reset_webhook, timeout=timeout, fast=fast)) + loop.create_task(self.dispatcher.start_polling(reset_webhook=reset_webhook, timeout=timeout, + relax=relax, fast=fast)) loop.run_forever() except (KeyboardInterrupt, SystemExit): # loop.stop()