Don't start the client in case run() is called with a coroutine as arg
This commit is contained in:
parent
4d324abbb5
commit
c30e8f9c55
@ -17,7 +17,6 @@
|
|||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import inspect
|
|
||||||
import logging
|
import logging
|
||||||
import math
|
import math
|
||||||
import mimetypes
|
import mimetypes
|
||||||
@ -452,21 +451,17 @@ class Client(Methods, BaseClient):
|
|||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
run = loop.run_until_complete
|
run = loop.run_until_complete
|
||||||
|
|
||||||
run(self.start())
|
if coroutine is not None:
|
||||||
|
run(coroutine)
|
||||||
|
else:
|
||||||
|
run(self.start())
|
||||||
|
run(self.idle())
|
||||||
|
|
||||||
run(
|
# TODO: Uncomment this once idle() gets refactored
|
||||||
coroutine if inspect.iscoroutine(coroutine)
|
# run(self.stop())
|
||||||
else coroutine() if coroutine
|
|
||||||
else self.idle()
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.is_started:
|
|
||||||
run(self.stop())
|
|
||||||
|
|
||||||
loop.close()
|
loop.close()
|
||||||
|
|
||||||
return coroutine
|
|
||||||
|
|
||||||
def add_handler(self, handler: Handler, group: int = 0):
|
def add_handler(self, handler: Handler, group: int = 0):
|
||||||
"""Register an update handler.
|
"""Register an update handler.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user