From 032571550acd5c231051ca4d823c5b4525819de8 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Wed, 9 Oct 2024 19:18:36 +0200 Subject: [PATCH] Lazy check connection --- supervisor/jobs/decorator.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/supervisor/jobs/decorator.py b/supervisor/jobs/decorator.py index 5f8934b21..f6b234499 100644 --- a/supervisor/jobs/decorator.py +++ b/supervisor/jobs/decorator.py @@ -383,7 +383,14 @@ class Job(CoreSysAttributes): ) if JobCondition.INTERNET_SYSTEM in used_conditions: - await coresys.sys_supervisor.check_connectivity() + # Connectivity check may take up to 10s (timeout) to complete, and + # hence slow down all exection. If we know connectivity is bad, + # schedule another connectivity check but fail immeaditly. + if coresys.sys_supervisor.connectivity: + await coresys.sys_supervisor.check_connectivity() + else: + coresys.sys_create_task(coresys.sys_supervisor.check_connectivity()) + if not coresys.sys_supervisor.connectivity: raise JobConditionException( f"'{method_name}' blocked from execution, no supervisor internet connection"