5.2.9. vlcp.event.ratelimiter

Note

This document is generated from the source file.

View Source on GitHub

Created on 2018/4/19

Preventing many time-consuming operations to be done in the same loop

author:hubo
class vlcp.event.ratelimiter.RateLimiter(limit, container)

Limit operations executed in current loop, ensure sockets are still processed in time-consuming operations

__init__(limit, container)
Parameters:
  • limit – “resources” limited in a single loop. “resources” can be any countable things like operations executed or bytes sent
  • container – a RoutineContainer
limit(use=1)

Acquire “resources”, wait until enough “resources” are acquired. For each loop, limit number of “resources” are permitted.

Parameters:use – number of “resouces” to be used.
Returns:True if is limited
class vlcp.event.ratelimiter.RateLimitingEvent(*args, **kwargs)