ppf: add periodic heartbeat and proxy reporting during test phase
All checks were successful
CI / validate (push) Successful in 20s
All checks were successful
CI / validate (push) Successful in 20s
This commit is contained in:
30
ppf.py
30
ppf.py
@@ -801,6 +801,8 @@ def worker_main(config):
|
|||||||
timeout_start = time.time()
|
timeout_start = time.time()
|
||||||
timeout_seconds = max(config.watchd.timeout * 2 + 30, len(all_jobs) * 0.5)
|
timeout_seconds = max(config.watchd.timeout * 2 + 30, len(all_jobs) * 0.5)
|
||||||
working_results = []
|
working_results = []
|
||||||
|
last_heartbeat = time.time()
|
||||||
|
last_report = time.time()
|
||||||
|
|
||||||
while completed < len(all_jobs):
|
while completed < len(all_jobs):
|
||||||
try:
|
try:
|
||||||
@@ -834,6 +836,34 @@ def worker_main(config):
|
|||||||
if time.time() - timeout_start > timeout_seconds:
|
if time.time() - timeout_start > timeout_seconds:
|
||||||
_log('test timeout, %d/%d completed' % (completed, len(all_jobs)), 'warn')
|
_log('test timeout, %d/%d completed' % (completed, len(all_jobs)), 'warn')
|
||||||
break
|
break
|
||||||
|
|
||||||
|
# Periodic heartbeat to prevent stale detection
|
||||||
|
now = time.time()
|
||||||
|
if now - last_heartbeat >= 60:
|
||||||
|
try:
|
||||||
|
worker_send_heartbeat(server_url, wstate['worker_key'],
|
||||||
|
True, current_tor_ip, worker_profiling, num_threads)
|
||||||
|
except NeedReregister:
|
||||||
|
do_register()
|
||||||
|
last_heartbeat = now
|
||||||
|
|
||||||
|
# Periodic proxy report (flush working results every 5 minutes)
|
||||||
|
if working_results and now - last_report >= 300:
|
||||||
|
try:
|
||||||
|
processed = worker_report_proxies(server_url, wstate['worker_key'],
|
||||||
|
working_results)
|
||||||
|
_log('interim report: %d working proxies (submitted %d)' % (
|
||||||
|
len(working_results), processed), 'info')
|
||||||
|
except NeedReregister:
|
||||||
|
do_register()
|
||||||
|
try:
|
||||||
|
processed = worker_report_proxies(server_url, wstate['worker_key'],
|
||||||
|
working_results)
|
||||||
|
except NeedReregister:
|
||||||
|
pass
|
||||||
|
working_results = []
|
||||||
|
last_report = now
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Populate proxy test cache from results
|
# Populate proxy test cache from results
|
||||||
|
|||||||
Reference in New Issue
Block a user