mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-05 12:40:22 +03:00
Fix updates
This commit is contained in:
parent
268e43d5c3
commit
6b2088873b
|
@ -6,7 +6,7 @@ import random
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from .users import UserMethods
|
from .users import UserMethods
|
||||||
from .. import events, utils, errors
|
from .. import syncio, events, utils, errors
|
||||||
from ..tl import types, functions
|
from ..tl import types, functions
|
||||||
|
|
||||||
__log__ = logging.getLogger(__name__)
|
__log__ = logging.getLogger(__name__)
|
||||||
|
@ -18,7 +18,7 @@ class UpdateMethods(UserMethods):
|
||||||
|
|
||||||
def _run_until_disconnected(self):
|
def _run_until_disconnected(self):
|
||||||
try:
|
try:
|
||||||
self.disconnected
|
self.disconnected.result()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
|
|
||||||
|
@ -32,17 +32,7 @@ class UpdateMethods(UserMethods):
|
||||||
If the loop is already running, this method returns a coroutine
|
If the loop is already running, this method returns a coroutine
|
||||||
that you should on your own code.
|
that you should on your own code.
|
||||||
"""
|
"""
|
||||||
if self.loop.is_running():
|
return self._run_until_disconnected()
|
||||||
return self._run_until_disconnected()
|
|
||||||
try:
|
|
||||||
return self.loop.run_until_complete(self.disconnected)
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
# Importing the magic sync module turns disconnect into sync.
|
|
||||||
# TODO Maybe disconnect() should not need the magic module...
|
|
||||||
if inspect.iscoroutinefunction(self.disconnect):
|
|
||||||
self.loop.run_until_complete(self.disconnect())
|
|
||||||
else:
|
|
||||||
self.disconnect()
|
|
||||||
|
|
||||||
def on(self, event):
|
def on(self, event):
|
||||||
"""
|
"""
|
||||||
|
@ -179,7 +169,7 @@ class UpdateMethods(UserMethods):
|
||||||
self._handle_update(update.update)
|
self._handle_update(update.update)
|
||||||
else:
|
else:
|
||||||
update._entities = getattr(update, '_entities', {})
|
update._entities = getattr(update, '_entities', {})
|
||||||
self._loop.create_task(self._dispatch_update(update))
|
syncio.create_task(self._dispatch_update, update)
|
||||||
|
|
||||||
need_diff = False
|
need_diff = False
|
||||||
if hasattr(update, 'pts'):
|
if hasattr(update, 'pts'):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user