getapi commited on
Commit
3c05d8e
·
verified ·
1 Parent(s): 4ef0474

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -97,7 +97,7 @@ async def stop_broker_after_timeout(broker: Broker, timeout_minutes: int):
97
  async def find_proxies_by_type(proxy_type: Literal['HTTP', 'HTTPS', 'SOCKS5'], output_json_file: Path, timeout_minutes: int = 50):
98
  output_json_file.write_text(dumps({'countries': None, 'proxies': []}, indent=4))
99
  proxies_queue = Queue()
100
- broker = Broker(proxies_queue, timeout=1, max_conn=200, max_tries=2, verify_ssl=True if proxy_type != 'HTTPS' else False)
101
  stop_task = create_task(stop_broker_after_timeout(broker, timeout_minutes))
102
  await broker.find(types=[proxy_type], countries=countries_list, limit=0)
103
  await stop_task
@@ -107,7 +107,7 @@ async def find_proxies_by_type(proxy_type: Literal['HTTP', 'HTTPS', 'SOCKS5'], o
107
 
108
  async def find_proxies():
109
  global is_first_run
110
- timeout_minutes = 5 if is_first_run else 50
111
  results = await gather(
112
  find_proxies_by_type('HTTP', http_collected_json, timeout_minutes),
113
  find_proxies_by_type('HTTPS', https_collected_json, timeout_minutes),
@@ -133,7 +133,7 @@ app = FastAPI(lifespan=app_lifespan)
133
 
134
 
135
  def not_redy_yet():
136
- return JSONResponse({"error": "ёще не готово, сбор и проверка прокси занимает около часа"}, status_code=204)
137
 
138
 
139
  @app.post('*')
 
97
  async def find_proxies_by_type(proxy_type: Literal['HTTP', 'HTTPS', 'SOCKS5'], output_json_file: Path, timeout_minutes: int = 50):
98
  output_json_file.write_text(dumps({'countries': None, 'proxies': []}, indent=4))
99
  proxies_queue = Queue()
100
+ broker = Broker(proxies_queue, timeout=2, max_conn=200, max_tries=3, verify_ssl=True if proxy_type != 'HTTPS' else False)
101
  stop_task = create_task(stop_broker_after_timeout(broker, timeout_minutes))
102
  await broker.find(types=[proxy_type], countries=countries_list, limit=0)
103
  await stop_task
 
107
 
108
  async def find_proxies():
109
  global is_first_run
110
+ timeout_minutes = 10 if is_first_run else 50
111
  results = await gather(
112
  find_proxies_by_type('HTTP', http_collected_json, timeout_minutes),
113
  find_proxies_by_type('HTTPS', https_collected_json, timeout_minutes),
 
133
 
134
 
135
  def not_redy_yet():
136
+ return JSONResponse({"error": "ёще не готово, сбор и проверка прокси занимает около часа"}, status_code=200)
137
 
138
 
139
  @app.post('*')