|
|
@@ -74,6 +74,16 @@ class SentinelGCO:
|
|
|
weights = [float(item.weight) for item in apt_types]
|
|
|
apt_type = random.choices(apt_types, weights=weights, k=1)[0]
|
|
|
|
|
|
+ interval = 30
|
|
|
+ mode = task.qw_cfg.mode
|
|
|
+ if mode == QueryWaitMode.Loop:
|
|
|
+ interval = 1
|
|
|
+ elif mode == QueryWaitMode.Fixed:
|
|
|
+ interval = task.qw_cfg.fixed_wait
|
|
|
+ elif mode == QueryWaitMode.Random:
|
|
|
+ interval = rng.randint(task.qw_cfg.random_min, task.qw_cfg.random_max)
|
|
|
+ task.next_run = time.time() + interval
|
|
|
+
|
|
|
try:
|
|
|
VSCloudApi.Instance().slot_refresh_start(apt_type.routing_key, country=apt_type.country, city=apt_type.city, visa_type=apt_type.visa_type)
|
|
|
result = task.instance.query(apt_type)
|
|
|
@@ -94,21 +104,11 @@ class SentinelGCO:
|
|
|
|
|
|
payload["query_result"]["website"] = self.m_cfg.website
|
|
|
VSCloudApi.Instance().slot_snapshot_report(payload["query_result"])
|
|
|
-
|
|
|
- interval = 30
|
|
|
- mode = task.qw_cfg.mode
|
|
|
- if mode == QueryWaitMode.Loop:
|
|
|
- interval = 1
|
|
|
- elif mode == QueryWaitMode.Fixed:
|
|
|
- interval = task.qw_cfg.fixed_wait
|
|
|
- elif mode == QueryWaitMode.Random:
|
|
|
- interval = rng.randint(task.qw_cfg.random_min, task.qw_cfg.random_max)
|
|
|
- task.next_run = time.time() + interval
|
|
|
|
|
|
except Exception as e:
|
|
|
self._log(f"Query exception: {e}")
|
|
|
VSCloudApi.Instance().slot_refresh_fail(apt_type.routing_key, error=str(e))
|
|
|
- task.next_run = time.time() + 10
|
|
|
+
|
|
|
except Exception as e:
|
|
|
self._log(f"Monitor loop error: {e}")
|
|
|
time.sleep(2)
|