From 07276e31b96a029d8789dd98ede1407adc52f771 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Fri, 11 Jan 2019 12:36:37 +0100 Subject: [PATCH] Add restart method --- docs/source/pyrogram/Client.rst | 1 + pyrogram/client/client.py | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/docs/source/pyrogram/Client.rst b/docs/source/pyrogram/Client.rst index 9a1b0509..f9e50d3e 100644 --- a/docs/source/pyrogram/Client.rst +++ b/docs/source/pyrogram/Client.rst @@ -13,6 +13,7 @@ Utilities start stop + restart idle run add_handler diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 7b5c1aea..61a3775b 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -374,6 +374,16 @@ class Client(Methods, BaseClient): return self + def restart(self): + """Use this method to restart the Client. + Requires no parameters. + + Raises: + ``ConnectionError`` in case you try to restart a stopped Client. + """ + self.stop() + self.start() + def idle(self, stop_signals: tuple = (SIGINT, SIGTERM, SIGABRT)): """Blocks the program execution until one of the signals are received, then gently stop the Client by closing the underlying connection.