mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-03 05:54:51 +00:00
Make start and stop methods return self to make chaining possible
Suggestion by @CharlesBachman in Telegram
This commit is contained in:
parent
6a9c7312cc
commit
001a067d82
1 changed files with 6 additions and 3 deletions
|
|
@ -198,10 +198,9 @@ class Client(Methods, BaseClient):
|
|||
self.dispatcher = Dispatcher(self, workers)
|
||||
|
||||
def __enter__(self):
|
||||
self.start()
|
||||
return self
|
||||
return self.start()
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
def __exit__(self, *args):
|
||||
self.stop()
|
||||
|
||||
@property
|
||||
|
|
@ -294,6 +293,8 @@ class Client(Methods, BaseClient):
|
|||
mimetypes.init()
|
||||
Syncer.add(self)
|
||||
|
||||
return self
|
||||
|
||||
def stop(self):
|
||||
"""Use this method to manually stop the Client.
|
||||
Requires no parameters.
|
||||
|
|
@ -331,6 +332,8 @@ class Client(Methods, BaseClient):
|
|||
self.is_started = False
|
||||
self.session.stop()
|
||||
|
||||
return self
|
||||
|
||||
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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue