@@ -74,8 +74,8 @@ async def process_proxies(self):
74
74
proxies = await db .execute (
75
75
Proxy .select ().where (
76
76
Proxy .number_of_bad_checks == 0 ,
77
- Proxy .last_check_time < time .time () - Proxy . checking_period ,
78
- ).order_by (Proxy .last_check_time ).limit (settings .NUMBER_OF_CONCURRENT_TASKS )
77
+ Proxy .next_check_time < time .time (),
78
+ ).order_by (Proxy .next_check_time ).limit (settings .NUMBER_OF_CONCURRENT_TASKS )
79
79
)
80
80
if proxies :
81
81
self .good_proxies_are_processed = False
@@ -92,8 +92,8 @@ async def process_proxies(self):
92
92
Proxy .select ().where (
93
93
Proxy .number_of_bad_checks > 0 ,
94
94
Proxy .number_of_bad_checks < settings .DEAD_PROXY_THRESHOLD ,
95
- Proxy .last_check_time < time .time () - settings . BAD_PROXY_CHECKING_PERIOD ,
96
- ).order_by (Proxy .last_check_time ).limit (settings .NUMBER_OF_CONCURRENT_TASKS )
95
+ Proxy .next_check_time < time .time (),
96
+ ).order_by (Proxy .next_check_time ).limit (settings .NUMBER_OF_CONCURRENT_TASKS )
97
97
)
98
98
99
99
await self .add_proxies_to_queue (proxies )
@@ -106,8 +106,8 @@ async def process_proxies(self):
106
106
Proxy .select ().where (
107
107
Proxy .number_of_bad_checks >= settings .DEAD_PROXY_THRESHOLD ,
108
108
Proxy .number_of_bad_checks < settings .DO_NOT_CHECK_ON_N_BAD_CHECKS ,
109
- Proxy .last_check_time < time .time () - settings . DEAD_PROXY_CHECKING_PERIOD ,
110
- ).order_by (Proxy .last_check_time ).limit (settings .NUMBER_OF_CONCURRENT_TASKS )
109
+ Proxy .next_check_time < time .time (),
110
+ ).order_by (Proxy .next_check_time ).limit (settings .NUMBER_OF_CONCURRENT_TASKS )
111
111
)
112
112
113
113
await self .add_proxies_to_queue (proxies )
@@ -293,6 +293,7 @@ async def process_proxy(self, raw_protocol: int, auth_data: str, domain: str, po
293
293
)
294
294
295
295
proxy .last_check_time = int (time .time ())
296
+ proxy .next_check_time = proxy .last_check_time + proxy .checking_period
296
297
proxy .number_of_bad_checks += 1
297
298
proxy .uptime = int (time .time ())
298
299
@@ -374,4 +375,8 @@ async def create_or_update_proxy(
374
375
+ (checking_time / settings .PROXY_CHECKING_TIMEOUT ) \
375
376
* (settings .MAX_PROXY_CHECKING_PERIOD - settings .MIN_PROXY_CHECKING_PERIOD )
376
377
378
+ # TODO: bad and not working proxies period
379
+
380
+ proxy .next_check_time = proxy .last_check_time + proxy .checking_period
381
+
377
382
await db .update (proxy )
0 commit comments