mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-03 13:14:31 +03:00
Raise AssertionError if trying to invoke requests from ReadThread
This commit is contained in:
parent
06b2834c02
commit
49e884b005
|
@ -205,6 +205,10 @@ class TelegramClient(TelegramBareClient):
|
|||
|
||||
*args will be ignored.
|
||||
"""
|
||||
if self._recv_thread is not None and \
|
||||
threading.get_ident() == self._recv_thread.ident:
|
||||
raise AssertionError('Cannot invoke requests from the ReadThread')
|
||||
|
||||
try:
|
||||
self._lock.acquire()
|
||||
|
||||
|
@ -213,11 +217,10 @@ class TelegramClient(TelegramBareClient):
|
|||
# will be the one which should be reading (but is invoking the
|
||||
# request) thus not being available to read it "in the background"
|
||||
# and it's needed to call receive.
|
||||
call_receive = self._recv_thread is None or \
|
||||
threading.get_ident() == self._recv_thread.ident
|
||||
|
||||
# TODO Retry if 'result' is None?
|
||||
return super().invoke(request, call_receive=call_receive)
|
||||
return super().invoke(
|
||||
request, call_receive=self._recv_thread is None
|
||||
)
|
||||
|
||||
except (PhoneMigrateError, NetworkMigrateError, UserMigrateError) as e:
|
||||
self._logger.debug('DC error when invoking request, '
|
||||
|
|
Loading…
Reference in New Issue
Block a user