Skip to content

Commit 6f3da84

Browse files
committed
Refresh domains schedule
1 parent 3c3e9eb commit 6f3da84

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

proxy/config.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,21 @@ def refresh_cfproxy_domains() -> None:
8787
proxy_config.active_cfproxy_domain = random.choice(pool)
8888

8989

90+
_refresh_stop: threading.Event = threading.Event()
91+
92+
9093
def start_cfproxy_domain_refresh() -> None:
91-
threading.Thread(
92-
target=refresh_cfproxy_domains,
93-
daemon=True,
94-
name='cfproxy-domains-refresh',
95-
).start()
94+
global _refresh_stop
95+
_refresh_stop.set()
96+
_refresh_stop = threading.Event()
97+
stop = _refresh_stop
98+
99+
def _loop():
100+
refresh_cfproxy_domains()
101+
while not stop.wait(timeout=3600):
102+
refresh_cfproxy_domains()
103+
104+
threading.Thread(target=_loop, daemon=True, name='cfproxy-domains-refresh').start()
96105

97106

98107
def parse_dc_ip_list(dc_ip_list: List[str]) -> Dict[int, str]:

0 commit comments

Comments
 (0)