Skip to content

Commit 07276e3

Browse files
committed
Add restart method
1 parent 19b8f64 commit 07276e3

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

docs/source/pyrogram/Client.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Utilities
1313

1414
start
1515
stop
16+
restart
1617
idle
1718
run
1819
add_handler

pyrogram/client/client.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,16 @@ def stop(self):
374374

375375
return self
376376

377+
def restart(self):
378+
"""Use this method to restart the Client.
379+
Requires no parameters.
380+
381+
Raises:
382+
``ConnectionError`` in case you try to restart a stopped Client.
383+
"""
384+
self.stop()
385+
self.start()
386+
377387
def idle(self, stop_signals: tuple = (SIGINT, SIGTERM, SIGABRT)):
378388
"""Blocks the program execution until one of the signals are received,
379389
then gently stop the Client by closing the underlying connection.

0 commit comments

Comments
 (0)