kafka_connector.timer

class kafka_connector.timer.Begin

Bases: enum.Enum

Variables:
  • IMMEDIATELY – 1
  • FULL_CENTISECOND – 2
  • FULL_DECISECOND – 3
  • FULL_SECOND – 4
  • FULL_MINUTE – 5
  • FULL_HOUR – 6
_member_type_

alias of object

class kafka_connector.timer.Timer(timer_function, interval=1, unit=<Unit.SECOND: 2>, begin=<Begin.FULL_SECOND: 4>)

Bases: object

Runs a predefined function every given interval

__init__(timer_function, interval=1, unit=<Unit.SECOND: 2>, begin=<Begin.FULL_SECOND: 4>)
Parameters:
  • timer_function (callable) – function which is called every interval step
  • interval (int) – interval step
  • unit (Unit) – unit for interval
  • begin (None or Begin or list of datetime.time) – Set start point. Either choose None for starting immediately, kafka_connector.timer.Begin elements or a list of datetime.time including start times. In the third case, the start time is set to the time which is the closest from the current timestamp.
__weakref__

list of weak references to the object (if defined)

is_started
Returns:If the timer has already been started
Return type:bool
is_stopped
Returns:If timer loop finished
Return type:bool
start()

Start timer and repeat calling self.timer_function every self.interval

stop()

Sets loop condition to false and timer loop will break in the next iteration. The current call of the timer_function will not be aborted.

static str_timedelta(seconds)

Stringify a timedelta from seconds in form x h x min x s :param seconds: number of seconds :type seconds: int

Returns:timedelta from seconds in form x h x min x s
Return type:str
class kafka_connector.timer.Unit

Bases: enum.Enum

Variables:
  • MILLISECOND – 1
  • SECOND – 2
  • MINUTE – 3
  • HOUR – 4
_member_type_

alias of object