pip_services3_commons.run.FixedRateTimer module
pip_services3_commons.run.FixedRateTimer
Fixed rate timer implementation
- copyright
Conceptual Vision Consulting LLC 2018-2019, see AUTHORS for more details.
- license
MIT, see LICENSE for more details.
-
class
pip_services3_commons.run.FixedRateTimer.
FixedRateTimer
(task_or_object: Any = None, interval: int = None, delay: int = None) Bases:
pip_services3_commons.run.IClosable.IClosable
Timer that is triggered in equal time intervals.
It has summetric cross-language implementation and is often used by Pip.Services toolkit to perform periodic processing and cleanup in microservices.
-
close
(correlation_id: Optional[str, None]) Closes the timer. This is __required by
IClosable
interface, but besides that it is identical to stop().- Parameters
correlation_id – (optional) transaction id to trace execution through call chain.
-
get_callback
() → Callable Gets the callback function that is called when this timer is triggered.
- Returns
the callback function or null if it is not set.
-
get_delay
() → int Gets initial delay before the timer is triggered for the first time.
- Returns
the delay in milliseconds.
-
get_task
() → <module ‘pip_services3_commons.run.INotifiable’ from ‘/pip_services3_commons/run/INotifiable.py’> Gets the INotifiable object that receives notifications from this timer.
- Returns
the INotifiable object or null if it is not set.
-
is_started
() → bool Checks if the timer is started.
- Returns
true if the timer is started and false if it is stopped.
-
set_callback
(value: Callable) Sets the callback function that is called when this timer is triggered.
- Parameters
value – the callback function to be called.
-
set_delay
(value: int) Sets initial delay before the timer is triggered for the first time. :param value: a delay in milliseconds.
-
set_interval
(value: int) Sets periodic timer triggering interval.
- Parameters
value – an interval in milliseconds.
-
set_task
(value: <module 'pip_services3_commons.run.INotifiable' from '/pip_services3_commons/run/INotifiable.py'>)
-
start
() Starts the timer. Initially the timer is triggered after __delay. After that it is triggered after __interval until it is stopped.
-
stop
() Stops the timer.
-
-
class
pip_services3_commons.run.FixedRateTimer.
Timer
(interval, delay, callback) Bases:
threading.Thread
-
run
() Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
-
stop
()
-