mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-26 02:26:30 +00:00
Fix THROTTLE_WAIT behavior
The concurrency QUEUE does not really QUEUE throttle limits.
This commit is contained in:
parent
7fcbc87db9
commit
5e170ab817
@ -522,18 +522,8 @@ class Job(CoreSysAttributes):
|
|||||||
time_since_last_call = datetime.now() - self.last_call(group_name)
|
time_since_last_call = datetime.now() - self.last_call(group_name)
|
||||||
throttle_period = self.throttle_period(group_name)
|
throttle_period = self.throttle_period(group_name)
|
||||||
if time_since_last_call < throttle_period:
|
if time_since_last_call < throttle_period:
|
||||||
# If we have queue concurrency (WAIT behavior), sleep until throttle period passes
|
# Always return False when throttled (skip execution)
|
||||||
if self.concurrency in (
|
return False
|
||||||
JobConcurrency.QUEUE,
|
|
||||||
JobConcurrency.GROUP_QUEUE,
|
|
||||||
):
|
|
||||||
sleep_time = (
|
|
||||||
throttle_period - time_since_last_call
|
|
||||||
).total_seconds()
|
|
||||||
await asyncio.sleep(sleep_time)
|
|
||||||
else:
|
|
||||||
# For non-queue concurrency (REJECT behavior), just return False
|
|
||||||
return False
|
|
||||||
elif self.throttle in (JobThrottle.RATE_LIMIT, JobThrottle.GROUP_RATE_LIMIT):
|
elif self.throttle in (JobThrottle.RATE_LIMIT, JobThrottle.GROUP_RATE_LIMIT):
|
||||||
# Only reprocess array when necessary (at limit)
|
# Only reprocess array when necessary (at limit)
|
||||||
if len(self.rate_limited_calls(group_name)) >= self.throttle_max_calls:
|
if len(self.rate_limited_calls(group_name)) >= self.throttle_max_calls:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user