mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-03 05:54:51 +00:00
Don't start the client in case run() is called with a coroutine as arg
This commit is contained in:
parent
4d324abbb5
commit
c30e8f9c55
1 changed files with 7 additions and 12 deletions
|
|
@ -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 a new issue