# -*- coding: utf-8 -*-
from __future__ import absolute_import
from abc import ABCMeta, abstractmethod
from concurrent.futures import ThreadPoolExecutor
Abstract class which defines all the available functionality.
Some methods are concrete, since they have a default
action only executed if not overriden.
__metaclass__ = ABCMeta
__disable__ = False
self.executor = ThreadPoolExecutor(max_workers=1)
[docs] def enable(self):
Returns a boolean that indicates whether the unit must be enabled or not.
By default it enabled.
[docs] def onSetup(self):
Actions to be executed only during startup.
The code is run asynchronously in a different thread than
the main code, so it is safe to execute blocking actions without blocking the whole IOLoop.
The method is called immediately after the daemon is started
or when the specified delay is passed.
**Important**: Due to the nature of the Tornado IOLoop, the @run_on_executor decorator
must be used in this function
[docs] def onStop(self):
Actions to be executed before the daemon is terminated
The method runs asynchronously in a different thread, just like
onSetup(), so it allows blocking behaviour.
[docs] def delay(self):
Indicates the delay (in seconds) to wait before executing the onSetup() function.
By default it returns 0
:return: The delay value in seconds
[docs] def onReload(self):
Actions to be executed when the reload signal is received.
[docs] def doReload(self):
Indicates whether the manager has reloading funcionality using an integer,
which represent the periodical reload time.
By default it returns 0.
:return: The number of seconds between reloadings.