Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4ae66e3

Browse files
added articles by exchange paged
1 parent 026fe33 commit 4ae66e3

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

‎src/main/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@ async def prefetch():
371371
total_prefetched = await prefetch_endpoints()
372372
app_logger.info(f"Cache Pre Fetched {total_prefetched} endpoints")
373373

374-
# wait for one hour 30 minutes then prefetch urls again
375-
await asyncio.sleep(60 * 60 * 3)
374+
# wait for 3 hours minutes then prefetch urls again
375+
await asyncio.sleep(60 * 60 * 3.5)
376376

377377
async def backup_cf_firewall_data():
378378
while True:
@@ -404,12 +404,12 @@ async def monitor_servers():
404404
asyncio.create_task(setup_cf_firewall())
405405
asyncio.create_task(backup_cf_firewall_data())
406406
asyncio.create_task(update_api_keys_background_task())
407-
# asyncio.create_task(prefetch())
408407
asyncio.create_task(process_credit_queue())
409408
asyncio.create_task(email_process.process_message_queues())
410409
asyncio.create_task(clean_up_memcache())
411410
asyncio.create_task(monitor_servers())
412411
asyncio.create_task(check_redis_errors())
412+
asyncio.create_task(prefetch())
413413

414414

415415
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
@@ -451,7 +451,7 @@ async def v1_gateway(request: Request, path: str):
451451
# Will Take at least six second on the cache if it finds nothing will return None
452452
# need an improved get timeout for the articles
453453
tasks = [redis_cache.get(key=api_url, timeout=60 * 5) for api_url in api_urls]
454-
app_logger.info("fetching responses")
454+
app_logger.info(f"fetching responses for {api_urls}")
455455
cached_responses = await asyncio.gather(*tasks)
456456
app_logger.info("fetched records")
457457
for i, response in enumerate(cached_responses):

‎src/prefetch/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ async def prefetch_endpoints() -> int:
99
"""will fetch the endpoints causing the endpoints to be cached"""
1010
urls = await build_dynamic_urls()
1111
# will wait for a maximum of 30 seconds for a response
12-
responses = awaitasyncio.gather(*[requester(_url, timeout=25) for_urlinurls])
13-
14-
forresponse, urlinzip(responses, urls):
12+
i = 0
13+
forurlinurls:
14+
response=awaitrequester(api_url=url, timeout=60*5)
1515
if response and response.get("status", False):
1616
await redis_cache.set(key=url, value=response)
1717
# this enables the gateway to process other requests while still prefetching urls
18-
await asyncio.sleep(delay=10)
19-
20-
return len(responses)
18+
await asyncio.sleep(delay=3)
19+
i+=1
20+
return i

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /