mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2026-04-06 23:53:31 +00:00
rename ratelimit decorator to script_ratelimit for clarity
script_ratelimit now defaults to None. add note in README
This commit is contained in:
@@ -89,7 +89,7 @@ class FactoryBase(VbanCmd):
|
||||
'streamname': 'Command1',
|
||||
'bps': 256000,
|
||||
'channel': 0,
|
||||
'script_ratelimit': 0.05, # 20 commands per second, to avoid overloading Voicemeeter
|
||||
'script_ratelimit': None, # if None or 0, no rate limit applied to script commands
|
||||
'timeout': 5, # timeout on socket operations, in seconds
|
||||
'disable_rt_listeners': False,
|
||||
'sync': False,
|
||||
|
||||
@@ -5,12 +5,12 @@ from typing import Iterator
|
||||
from .error import VBANCMDConnectionError
|
||||
|
||||
|
||||
def ratelimit(func):
|
||||
"""ratelimit decorator for {VbanCmd}.sendtext, to prevent flooding the network with script requests."""
|
||||
def script_ratelimit(func):
|
||||
"""script_ratelimit decorator for {VbanCmd}.sendtext, to prevent flooding the network with script requests."""
|
||||
|
||||
def wrapper(*args, **kwargs):
|
||||
self, *rem = args
|
||||
if self.script_ratelimit > 0:
|
||||
if self.script_ratelimit:
|
||||
now = time.time()
|
||||
elapsed = now - self._last_script_request_time
|
||||
if elapsed < self.script_ratelimit:
|
||||
|
||||
Reference in New Issue
Block a user