diff --git a/main.py b/main.py index 3dc627a..d442484 100644 --- a/main.py +++ b/main.py @@ -20,17 +20,17 @@ schema = make_executable_schema(load_schema_from_path("inbox.graphql"), resolver async def start_up(): - await redis.connect() + try: + await redis.connect() - await CacheStorage.init() + await CacheStorage.init() - if MODE == "dev": - if not exists(DEV_SERVER_PID_FILE_NAME): - with open(DEV_SERVER_PID_FILE_NAME, "w", encoding="utf-8") as f: - f.write(str(os.getpid())) - else: - # startup sentry monitoring services - try: + if MODE == "dev": + if not exists(DEV_SERVER_PID_FILE_NAME): + with open(DEV_SERVER_PID_FILE_NAME, "w", encoding="utf-8") as f: + f.write(str(os.getpid())) + else: + # startup sentry monitoring services import sentry_sdk sentry_sdk.init( @@ -42,9 +42,11 @@ async def start_up(): AioHttpIntegration(), ], ) - except Exception as e: - print("[sentry] init error") - print(e) + except Exception as e: + print("STARTUP FAILED") + import traceback + + traceback.print_exc() async def shutdown(): diff --git a/resolvers/load.py b/resolvers/load.py index 769bdb8..674a36f 100644 --- a/resolvers/load.py +++ b/resolvers/load.py @@ -94,7 +94,7 @@ async def load_chats(_, info, limit: int = 50, offset: int = 0) -> Dict[str, Uni member_ids = c["members"].copy() c["members"] = [] for member_id in member_ids: - a = CacheStorage.authors_by_id.get(member_id) + a = CacheStorage.authors_by_id.get(str(member_id)) if a: a["online"] = a.get("id") in members_online c["members"].append(a) diff --git a/resolvers/search.py b/resolvers/search.py index 4e9b426..f055652 100644 --- a/resolvers/search.py +++ b/resolvers/search.py @@ -25,7 +25,7 @@ async def search_recipients(_, info, text: str, limit: int = 50, offset: int = 0 members_ids = await redis.execute("SMEMBERS", f"/chats/{chat_id}/members") if isinstance(members_ids, set): for member_id in members_ids: - author = CacheStorage.authors_by_id.get(member_id) + author = CacheStorage.authors_by_id.get(str(member_id)) if author: if author["name"].startswith(text): result.add(author) diff --git a/services/core.py b/services/core.py index 3eda1f5..b4d30e4 100644 --- a/services/core.py +++ b/services/core.py @@ -94,7 +94,7 @@ class CacheStorage: CacheStorage.authors = result for a in result: user_id = a.get("user") - author_id = a.get("id") + author_id = str(a.get("id")) self.authors_by_user[user_id] = a self.authors_by_id[author_id] = a