Update docstrings Args->Keyword Args for tickerhandler. Resolve #2723

This commit is contained in:
Griatch 2022-11-27 18:37:50 +01:00
parent da03b22e1c
commit c97dbe6915

View file

@ -68,13 +68,12 @@ call the handler's `save()` and `restore()` methods when the server reboots.
import inspect import inspect
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from twisted.internet.defer import inlineCallbacks
from evennia.scripts.scripts import ExtendedLoopingCall from evennia.scripts.scripts import ExtendedLoopingCall
from evennia.server.models import ServerConfig from evennia.server.models import ServerConfig
from evennia.utils import inherits_from, variable_from_module from evennia.utils import inherits_from, variable_from_module
from evennia.utils.dbserialize import dbserialize, dbunserialize, pack_dbobj from evennia.utils.dbserialize import dbserialize, dbunserialize, pack_dbobj
from evennia.utils.logger import log_err, log_trace from evennia.utils.logger import log_err, log_trace
from twisted.internet.defer import inlineCallbacks
_GA = object.__getattribute__ _GA = object.__getattribute__
_SA = object.__setattr__ _SA = object.__setattr__
@ -174,7 +173,7 @@ class Ticker(object):
using it. using it.
Args: Args:
start_delay (int): Time to way before starting. start_delay (int, optional): Time to way before starting.
""" """
subs = self.subscriptions subs = self.subscriptions
@ -286,8 +285,7 @@ class TickerPool(object):
restoring the pool will automatically re-populate the pool. restoring the pool will automatically re-populate the pool.
Args: Args:
interval (int, optional): Only stop tickers with this interval (int, optional): Only stop tickers with this interval.
interval.
""" """
if interval and interval in self.tickers: if interval and interval in self.tickers:
@ -495,22 +493,26 @@ class TickerHandler(object):
Add subscription to tickerhandler Add subscription to tickerhandler
Args: Args:
interval (int, optional): Interval in seconds between calling
*args: Will be passed into the callback every time it's called. This must be
data possible to pickle.
Keyword Args:
interval (int): Interval in seconds between calling
`callable(*args, **kwargs)` `callable(*args, **kwargs)`
callable (callable function or method, optional): This callable (callable function or method): This
should either be a stand-alone function or a method on a should either be a stand-alone function or a method on a
typeclassed entity (that is, one that can be saved to the typeclassed entity (that is, one that can be saved to the
database). database).
idstring (str, optional): Identifier for separating idstring (str): Identifier for separating
this ticker-subscription from others with the same this ticker-subscription from others with the same
interval. Allows for managing multiple calls with interval. Allows for managing multiple calls with
the same time interval and callback. the same time interval and callback.
persistent (bool, optional): A ticker will always survive persistent (bool): A ticker will always survive
a server reload. If this is unset, the ticker will be a server reload. If this is unset, the ticker will be
deleted by a server shutdown. deleted by a server shutdown.
args, kwargs (optional): These will be passed into the **kwargs Will be passed into the callback every time it is called.
callback every time it is called. This must be data possible This must be data possible to pickle.
to pickle!
Returns: Returns:
store_key (tuple): The immutable store-key for this ticker. This can store_key (tuple): The immutable store-key for this ticker. This can
@ -539,13 +541,13 @@ class TickerHandler(object):
""" """
Remove ticker subscription from handler. Remove ticker subscription from handler.
Args: Keyword Args:
interval (int, optional): Interval of ticker to remove. interval (int): Interval of ticker to remove.
callback (callable function or method): Either a function or callback (callable function or method): Either a function or
the method of a typeclassed object. the method of a typeclassed object.
idstring (str, optional): Identifier id of ticker to remove. idstring (str): Identifier id of ticker to remove.
persistent (bool, optional): Whether this ticker is persistent or not. persistent (bool): Whether this ticker is persistent or not.
store_key (str, optional): If given, all other kwargs are ignored and only store_key (str): If given, all other kwargs are ignored and only
this is used to identify the ticker. this is used to identify the ticker.
Raises: Raises:
@ -576,7 +578,7 @@ class TickerHandler(object):
Stop/remove tickers from handler. Stop/remove tickers from handler.
Args: Args:
interval (int): Only stop tickers with this interval. interval (int, optional): Only stop tickers with this interval.
Notes: Notes:
This is the only supported way to kill tickers related to This is the only supported way to kill tickers related to
@ -596,16 +598,15 @@ class TickerHandler(object):
def all(self, interval=None): def all(self, interval=None):
""" """
Get all subscriptions. Get all ticker subscriptions.
Args: Args:
interval (int): Limit match to tickers with this interval. interval (int, optional): Limit match to tickers with this interval.
Returns: Returns:
tickers (list): If `interval` was given, this is a list of list or dict: If `interval` was given, this is a list of tickers using that interval.
tickers using that interval. If `interval` was *not* given, this is a dict
tickerpool_layout (dict): If `interval` was *not* given, `{interval1: [ticker1, ticker2, ...], ...}`
this is a dict {interval1: [ticker1, ticker2, ...], ...}
""" """
if interval is None: if interval is None: