Revert "Workaround for None results"

This reverts commit 6e4c437340.
This commit is contained in:
Lonami Exo 2017-04-11 09:46:26 +02:00
parent 6e4c437340
commit 3e611cdd42

View File

@ -160,7 +160,7 @@ class TelegramClient:
# region Telegram requests functions
def invoke(self, request, timeout=timedelta(seconds=5), throw_invalid_dc=False, tries=3, expect_result=True):
def invoke(self, request, timeout=timedelta(seconds=5), throw_invalid_dc=False):
"""Invokes a MTProtoRequest (sends and receives it) and returns its result.
An optional timeout can be given to cancel the operation after the time delta.
Timeout can be set to None for no timeout.
@ -174,14 +174,7 @@ class TelegramClient:
self.sender.send(request)
self.sender.receive(request, timeout)
if request.result is None and expect_result:
if tries == 0:
raise ValueError('The result of the invoked request is always None')
else:
return self.invoke(request, timeout, throw_invalid_dc, tries - 1, expect_result)
else:
# Either the result is not None or we don't expect it to be different
return request.result
return request.result
except InvalidDCError as error:
if throw_invalid_dc:
@ -267,7 +260,7 @@ class TelegramClient:
def log_out(self):
"""Logs out and deletes the current session. Returns True if everything went OK"""
try:
self.invoke(LogOutRequest(), expect_result=False)
self.invoke(LogOutRequest())
if not self.session.delete():
return False