MessageQueue(all_burst_limit=30, all_time_limit_ms=1000, group_burst_limit=20, group_time_limit_ms=60000, exc_route=None, autostart=True)¶
Implements callback processing with proper delays to avoid hitting Telegram’s message limits. Contains two
DelayQueue, for group and for all messages, interconnected in delay chain. Callables are processed through group
DelayQueue, then through all
DelayQueuefor group-type messages. For non-group messages, only the all
int, optional) – Number of maximum all-type callbacks to process per time-window defined by
all_time_limit_ms. Defaults to 30.
int, optional) – Defines width of all-type time-window used when each processing limit is calculated. Defaults to 1000 ms.
int, optional) – Number of maximum group-type callbacks to process per time-window defined by
group_time_limit_ms. Defaults to 20.
int, optional) – Defines width of group-type time-window used when each processing limit is calculated. Defaults to 60000 ms.
callable, optional) – A callable, accepting one positional argument; used to route exceptions from processor threads to main thread; is called on
Exceptionsubclass exceptions. If not provided, exceptions are routed through dummy handler, which re-raises them.
bool, optional) – If
True, processors are started immediately after object’s creation; if
False, should be started manually by
startmethod. Defaults to
Processes callables in throughput-limiting queues to avoid hitting limits (specified with
callable) – Mainly the
telegram.utils.promise.Promise(see Notes for other callables), that is processed in delay queues.
bool, optional) – Defines whether
promisewould be processed in group*+*all*
DelayQueue``s (if set to :obj:`True`), or only through *all* ``DelayQueue(if set to
False), resulting in needed delays to avoid hitting specified limits. Defaults to
Method is designed to accept
promiseargument, but other callables could be used too. For example, lambdas or simple functions could be used to wrap original func to be called with needed args. In that case, be sure that either wrapper func does not raise outside exceptions or the proper
exc_routehandler is provided.
- Return type
__init__(all_burst_limit=30, all_time_limit_ms=1000, group_burst_limit=20, group_time_limit_ms=60000, exc_route=None, autostart=True)¶
Initialize self. See help(type(self)) for accurate signature.
list of weak references to the object (if defined)
Method is used to manually start the
Used to gently stop processor and shutdown its thread.
float) – Indicates maximum time to wait for processor to stop and its thread to exit. If timeout exceeds and processor has not stopped, method silently returns.
is_alivecould be used afterwards to check the actual status.
None, blocks until processor is shut down. Defaults to