Skip to content

Commit

Permalink
logging when process got killed
Browse files Browse the repository at this point in the history
  • Loading branch information
z44d committed Jun 27, 2024
1 parent fc1a8b4 commit ce3c853
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tgram/sync.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
# Copyright (C) 2024 Zaid <https://github.com/2ei>
#
# This file is part of Pyrogram.
#
Expand All @@ -20,6 +20,9 @@
import functools
import inspect
import threading
import logging

logger = logging.getLogger(__name__)


def async_to_sync(obj, name):
Expand Down Expand Up @@ -64,7 +67,10 @@ def async_to_sync_wrap(*args, **kwargs):
return coroutine
else:
if inspect.iscoroutine(coroutine):
return loop.run_until_complete(coroutine)
try:
return loop.run_until_complete(coroutine)
except (asyncio.CancelledError, KeyboardInterrupt):
logger.info("\nThe process %s got killed", coroutine.__name__)

if inspect.isasyncgen(coroutine):
return async_to_sync_gen(coroutine, loop, True)
Expand Down

0 comments on commit ce3c853

Please sign in to comment.