mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-23 09:06:29 +00:00
Handle group options for concurrency and throttle separately
This commit is contained in:
parent
d95048ed60
commit
24a65dccd5
@ -239,15 +239,22 @@ class Job(CoreSysAttributes):
|
|||||||
job_group = cast(JobGroup, obj)
|
job_group = cast(JobGroup, obj)
|
||||||
|
|
||||||
# Check for group-based parameters
|
# Check for group-based parameters
|
||||||
group_based_params = [
|
if not job_group:
|
||||||
self.concurrency
|
if self.concurrency in (
|
||||||
in (JobConcurrency.GROUP_REJECT, JobConcurrency.GROUP_QUEUE),
|
JobConcurrency.GROUP_REJECT,
|
||||||
self.throttle in (JobThrottle.GROUP_THROTTLE, JobThrottle.GROUP_RATE_LIMIT),
|
JobConcurrency.GROUP_QUEUE,
|
||||||
]
|
):
|
||||||
|
|
||||||
if not job_group and any(group_based_params):
|
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
f"Job on {self.name} need to be a JobGroup to use group based limits!"
|
f"Job {self.name} uses group concurrency ({self.concurrency}) but is not on a JobGroup! "
|
||||||
|
f"The class must inherit from JobGroup to use GROUP_REJECT or GROUP_QUEUE."
|
||||||
|
) from None
|
||||||
|
if self.throttle in (
|
||||||
|
JobThrottle.GROUP_THROTTLE,
|
||||||
|
JobThrottle.GROUP_RATE_LIMIT,
|
||||||
|
):
|
||||||
|
raise RuntimeError(
|
||||||
|
f"Job {self.name} uses group throttling ({self.throttle}) but is not on a JobGroup! "
|
||||||
|
f"The class must inherit from JobGroup to use GROUP_THROTTLE or GROUP_RATE_LIMIT."
|
||||||
) from None
|
) from None
|
||||||
|
|
||||||
return job_group
|
return job_group
|
||||||
|
Loading…
x
Reference in New Issue
Block a user