|
|
@@ -3,6 +3,7 @@ import time
|
|
|
import json
|
|
|
import threading
|
|
|
import random
|
|
|
+from datetime import datetime
|
|
|
from typing import List, Dict, Callable
|
|
|
|
|
|
from vs_types import GroupConfig, VSPlgConfig, Task, VSQueryResult, AppointmentType
|
|
|
@@ -92,6 +93,17 @@ class BuiltinBookerGCO:
|
|
|
|
|
|
def _get_redis_key(self, routing_key: str) -> str:
|
|
|
return f"vs:signal:{routing_key}"
|
|
|
+
|
|
|
+ def _is_within_active_hours(self) -> bool:
|
|
|
+ """
|
|
|
+ 判断当前是否在允许创建实例的时间段内
|
|
|
+ """
|
|
|
+ start_str = self.m_cfg.active_time_start
|
|
|
+ end_str = self.m_cfg.active_time_end
|
|
|
+ current_bj_time = datetime.now().time()
|
|
|
+ start_time = datetime.strptime(start_str, "%H:%M").time()
|
|
|
+ end_time = datetime.strptime(end_str, "%H:%M").time()
|
|
|
+ return start_time <= current_bj_time <= end_time
|
|
|
|
|
|
def _maintain_loop(self):
|
|
|
self._log("Maintain loop started.")
|
|
|
@@ -246,9 +258,11 @@ class BuiltinBookerGCO:
|
|
|
|
|
|
def _creator_loop(self):
|
|
|
self._log("Creator loop started.")
|
|
|
- while not self.m_stop_event.is_set():
|
|
|
+ while not self.m_stop_event.wait(1.0):
|
|
|
try:
|
|
|
- time.sleep(1.0)
|
|
|
+ if not self._is_within_active_hours():
|
|
|
+ continue
|
|
|
+
|
|
|
with self.m_lock:
|
|
|
current = len(self.m_tasks)
|
|
|
target = self.m_cfg.booker.target_instances
|