How to use the tempora.schedule.Scheduler function in tempora

To help you get started, we’ve selected a few tempora examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pajbot / pajbot / pajbot / eventloop.py View on Github external
import logging
from irc.schedule import IScheduler
from tempora import schedule
from tempora.schedule import Scheduler


log = logging.getLogger(__name__)


# same as InvokeScheduler from the original implementation,
# but with the extra try-catch
class SafeInvokeScheduler(Scheduler):
    """
    Command targets are functions to be invoked on schedule.
    """

    def run(self, command):
        try:
            command.target()
        except Exception:
            # we do "exception Exception" to not catch KeyboardInterrupt and SystemExit
            # (so the bot can properly quit)
            log.exception("Logging an uncaught exception (main thread)")


# same as DefaultScheduler from the original implementation,
# but extends SafeInvokeScheduler instead
class SafeDefaultScheduler(SafeInvokeScheduler, IScheduler):