mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-03-03 19:00:21 +03:00
Fix __del__ with sync magic
This commit is contained in:
parent
75dc4809f5
commit
d4b508bf48
|
@ -4,7 +4,7 @@ import logging
|
||||||
import platform
|
import platform
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import warnings
|
import inspect
|
||||||
from datetime import timedelta, datetime
|
from datetime import timedelta, datetime
|
||||||
|
|
||||||
from .. import version
|
from .. import version
|
||||||
|
@ -302,7 +302,9 @@ class TelegramBaseClient(abc.ABC):
|
||||||
# able to close the pending tasks properly, and letting the script
|
# able to close the pending tasks properly, and letting the script
|
||||||
# complete without calling disconnect causes the script to trigger
|
# complete without calling disconnect causes the script to trigger
|
||||||
# 100% CPU load. Call disconnect to make sure it doesn't happen.
|
# 100% CPU load. Call disconnect to make sure it doesn't happen.
|
||||||
if self._loop.is_running():
|
if not inspect.iscoroutinefunction(self.disconnect):
|
||||||
|
self.disconnect()
|
||||||
|
elif self._loop.is_running():
|
||||||
self._loop.create_task(self.disconnect())
|
self._loop.create_task(self.disconnect())
|
||||||
else:
|
else:
|
||||||
self._loop.run_until_complete(self.disconnect())
|
self._loop.run_until_complete(self.disconnect())
|
||||||
|
|
Loading…
Reference in New Issue
Block a user