author-with-stat-cache-nonblock-2
Some checks failed
Deploy on push / deploy (push) Failing after 9s

This commit is contained in:
2024-06-11 17:51:34 +03:00
parent b2fdc9a453
commit 04e20b29ee
4 changed files with 30 additions and 14 deletions

View File

@@ -1,3 +1,5 @@
import asyncio
from sqlalchemy import and_, distinct, func, join, select
from sqlalchemy.orm import aliased
@@ -260,9 +262,12 @@ def author_follows_topics(author_id: int):
async def update_author_stat(author_id: int):
author_query = select(Author).where(Author.id == author_id)
try:
[author_with_stat] = get_with_stat(author_query)
if isinstance(author_with_stat, Author):
author_dict = author_with_stat.dict()
await cache_author(author_dict)
result = get_with_stat(author_query)
if result and len(result) == 1:
author_with_stat = result[0]
if isinstance(author_with_stat, Author):
author_dict = author_with_stat.dict()
# await cache_author(author_dict)
asyncio.create_task(cache_author(author_dict))
except Exception as exc:
logger.error(exc, exc_info=True)