Fast-mode in executor

This commit is contained in:
Alex Root Junior 2018-09-22 23:57:00 +03:00
parent 76b5983730
commit 5c98395620

View file

@ -20,7 +20,7 @@ def _setup_callbacks(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=None):
on_startup=None, on_shutdown=None, timeout=None, fast=True):
"""
Start bot in long-polling mode
@ -35,7 +35,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)
executor.start_polling(reset_webhook=reset_webhook, timeout=timeout, fast=fast)
def start_webhook(dispatcher, webhook_path, *, loop=None, skip_updates=None,
@ -234,7 +234,7 @@ class Executor:
web.run_app(self._web_app, **kwargs)
def start_polling(self, reset_webhook=None, timeout=None):
def start_polling(self, reset_webhook=None, timeout=None, fast=True):
"""
Start bot in long-polling mode
@ -246,7 +246,7 @@ class Executor:
try:
loop.run_until_complete(self._startup_polling())
loop.create_task(self.dispatcher.start_polling(reset_webhook=reset_webhook, timeout=timeout))
loop.create_task(self.dispatcher.start_polling(reset_webhook=reset_webhook, timeout=timeout, fast=fast))
loop.run_forever()
except (KeyboardInterrupt, SystemExit):
# loop.stop()