<commit_before>#!/usr/bin/env python

__author__ = 'Seman, <NAME>'
__license__ = 'Apache 2.0'

from pyon.public import IonObject, RT, log
from pyon.core.exception import BadRequest
from pyon.event.event import EventPublisher
from pyon.core.bootstrap import CFG
from interface.services.cei.ischeduler_service import BaseSchedulerService
from interface.objects import IntervalTimer, TimeOfDayTimer

from datetime import datetime, timedelta
from math import ceil
import time
import gevent


class SchedulerService(BaseSchedulerService):

    def __init__(self, *args, **kwargs):
        BaseSchedulerService.__init__(self, *args, **kwargs)

        self.schedule_entries = {}
        self._no_reschedule = False

    def on_start(self):
        if CFG.get_safe("process.start_mode") == "RESTART":
            self.on_system_restart()
        self.pub = EventPublisher(event_type="TimerEvent")

    def on_quit(self):
        self.pub.close()

        # throw killswitch on future reschedules
        self._no_reschedule = True

        # terminate any pending spawns
        self._stop_pending_timers()

    def _notify(self, task, id_, index):
        log.debug("SchedulerService:_notify: - " + task.event_origin + " - Time: " + str(self._now()) + " - id_: " + id_ + " -Index:" + str(index))
        self.pub.publish_event(origin=task.event_origin)

    def _now(self):
        return datetime.utcnow()

    def _convert_to_posix_time(self, t):
        return time.mktime(t.timetuple())<commit_msg>Updated scheduler service to support process or bootmode restart<commit_after>#!/usr/bin/env python

__author__ = 'Seman, <NAME>'
__license__ = 'Apache 2.0'

from pyon.public import IonObject, RT, log
from pyon.core.exception import BadRequest
from pyon.event.event import EventPublisher
from pyon.core.bootstrap import CFG
from interface.services.cei.ischeduler_service import BaseSchedulerService
from interface.objects import IntervalTimer, TimeOfDayTimer

from datetime import datetime, timedelta
from math import ceil
import time
import gevent


class SchedulerService(BaseSchedulerService):

    def __init__(self, *args, **kwargs):
        BaseSchedulerService.__init__(self, *args, **kwargs)

        self.schedule_entries = {}
        self._no_reschedule = False

    def on_start(self):
        if CFG.get_safe("process.start_mode") == "RESTART" or CFG.get_safe("bootmode") == "restart":
            self.on_system_restart()
        self.pub = EventPublisher(event_type="TimerEvent")

    def on_quit(self):
        self.pub.close()

        # throw killswitch on future reschedules
        self._no_reschedule = True

        # terminate any pending spawns
        self._stop_pending_timers()

    def _notify(self, task, id_, index):
        log.debug("SchedulerService:_notify: - " + task.event_origin + " - Time: " + str(self._now()) + " - id_: " + id_ + " -Index:" + str(index))
        self.pub.publish_event(origin=task.event_origin)

    def _now(self):
        return datetime.utcnow()

    def _convert_to_posix_time(self, t):
        return time.mktime(t.timetuple())
{'fraction_non_alphanumeric': 0.10603112840466926, 'fraction_numerical': 0.0012970168612191958, 'mean_word_length': 3.550147492625369, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3503071', 'n_tokens_mistral': 973, 'n_tokens_neox': 930, 'n_words': 222}