File tree Expand file tree Collapse file tree 1 file changed +0
-19
lines changed
Expand file tree Collapse file tree 1 file changed +0
-19
lines changed Original file line number Diff line number Diff line change 3434 allow_headers = ["*" ],
3535)
3636
37- cache_ttl_secs = 600
38- api_cache = LRUCache (maxseze = 1000 )
39-
4037def get_proxy ():
4138 proxy = FreeProxy (rand = True , timeout = 1 ).get ()
4239 return proxy
4340
44- async def get_data_from_api (url , session ):
45- async with async_timeout .timeout (cache_ttl_secs ):
46- async with session .get (url ) as response :
47- data = await response .json ()
48- api_cache [url ] = (data , datetime .now ())
49- return data
5041
5142@app .post ("/chat/completions" )
5243@app .post ("/v1/chat/completions" )
@@ -322,16 +313,6 @@ async def run_check_script():
322313 # Pause for 5 minutes before starting the next cycle
323314 time .sleep (360 )
324315
325- # Асинхронная функция для обновления кэша данных из API
326- async def update_api_cache ():
327- while True :
328- try :
329- # Обновление данных каждые 10 минут
330- await asyncio .sleep (360 )
331- api_cache .clear ()
332- except :
333- pass
334-
335316# Запуск асинхронных задач
336317async def run_tasks ():
337318 while True :
You can’t perform that action at this time.
0 commit comments