mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2026-03-12 04:59:09 +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:
parent
242401e294
commit
09259269d7
@ -548,7 +548,7 @@ You may pass the following optional keyword arguments:
|
|||||||
- `channel`: int=0, channel on which to send the UDP requests.
|
- `channel`: int=0, channel on which to send the UDP requests.
|
||||||
- `pdirty`: boolean=False, parameter updates
|
- `pdirty`: boolean=False, parameter updates
|
||||||
- `ldirty`: boolean=False, level updates
|
- `ldirty`: boolean=False, level updates
|
||||||
- `script_ratelimit`: float=0.05, default to 20 script requests per second. This affects vban.sendtext() specifically.
|
- `script_ratelimit`: float | None=None, ratelimit for vban.sendtext() specifically.
|
||||||
- `timeout`: int=5, timeout for socket operations.
|
- `timeout`: int=5, timeout for socket operations.
|
||||||
- `disable_rt_listeners`: boolean=False, set `True` if you don't wish to receive RT packets.
|
- `disable_rt_listeners`: boolean=False, set `True` if you don't wish to receive RT packets.
|
||||||
- You can still send Matrix string requests ending with `?` and receive a response.
|
- You can still send Matrix string requests ending with `?` and receive a response.
|
||||||
|
|||||||
@ -89,7 +89,7 @@ class FactoryBase(VbanCmd):
|
|||||||
'streamname': 'Command1',
|
'streamname': 'Command1',
|
||||||
'bps': 256000,
|
'bps': 256000,
|
||||||
'channel': 0,
|
'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
|
'timeout': 5, # timeout on socket operations, in seconds
|
||||||
'disable_rt_listeners': False,
|
'disable_rt_listeners': False,
|
||||||
'sync': False,
|
'sync': False,
|
||||||
|
|||||||
@ -5,12 +5,12 @@ from typing import Iterator
|
|||||||
from .error import VBANCMDConnectionError
|
from .error import VBANCMDConnectionError
|
||||||
|
|
||||||
|
|
||||||
def ratelimit(func):
|
def script_ratelimit(func):
|
||||||
"""ratelimit decorator for {VbanCmd}.sendtext, to prevent flooding the network with script requests."""
|
"""script_ratelimit decorator for {VbanCmd}.sendtext, to prevent flooding the network with script requests."""
|
||||||
|
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
self, *rem = args
|
self, *rem = args
|
||||||
if self.script_ratelimit > 0:
|
if self.script_ratelimit:
|
||||||
now = time.time()
|
now = time.time()
|
||||||
elapsed = now - self._last_script_request_time
|
elapsed = now - self._last_script_request_time
|
||||||
if elapsed < self.script_ratelimit:
|
if elapsed < self.script_ratelimit:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user