當前位置: 首頁>>代碼示例>>Python>>正文


Python sched.scheduler方法代碼示例

本文整理匯總了Python中sched.scheduler方法的典型用法代碼示例。如果您正苦於以下問題:Python sched.scheduler方法的具體用法?Python sched.scheduler怎麽用?Python sched.scheduler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sched的用法示例。


在下文中一共展示了sched.scheduler方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: start

# 需要導入模塊: import sched [as 別名]
# 或者: from sched import scheduler [as 別名]
def start(self):
    """Schedule start/stop profiler event specified in profiler_enabled_time_str."""

    if not self.profiler_enabled_time_str:
      return

    last_end_time = -1
    for time_str in self.profiler_enabled_time_str.split(','):
      begin_time = int(time_str.split(':')[0].strip())
      end_time_str = time_str.split(':')[1].strip() if ':' in time_str else None
      end_time = int(end_time_str) if end_time_str else 365 * 24 * 60 * 60
      if begin_time <= last_end_time:
        raise ValueError('begin_time {} is no larger than the last '
                         'end_time {}'.format(begin_time, last_end_time))
      if end_time <= begin_time:
        raise ValueError('end_time {} is no larger than begin_time {}'.format(
            end_time, begin_time))
      # 4th positional arg added to support Python2 for the short-term.
      self.scheduler.enter(begin_time, 1, _start_profiler, ())  # pylint: disable=no-value-for-parameter
      self.scheduler.enter(end_time, 1, _stop_and_save_profiler,
                           argument=(self.output_dir,))
      last_end_time = end_time

    threading.Thread(target=self.scheduler.run).start() 
開發者ID:tensorflow,項目名稱:benchmarks,代碼行數:26,代碼來源:tensorflow_profiler.py

示例2: stop

# 需要導入模塊: import sched [as 別名]
# 或者: from sched import scheduler [as 別名]
def stop(self):
    """Stop scheduler and save profiler data if any event is cancelled."""

    event_canceled = False
    for event in self.scheduler.queue:
      try:
        self.scheduler.cancel(event)
        event_canceled = True
      except ValueError:
        # This is OK because the event may have been just canceled
        pass

    # Signal the scheduler thread to stop sleeping
    self.exit_event.set()

    # Save the profiler data if any event is canceled
    if event_canceled:
      _stop_and_save_profiler(self.output_dir) 
開發者ID:tensorflow,項目名稱:benchmarks,代碼行數:20,代碼來源:tensorflow_profiler.py

示例3: __reschedule_update_in

# 需要導入模塊: import sched [as 別名]
# 或者: from sched import scheduler [as 別名]
def __reschedule_update_in(self, minutes):
      '''
      clean up scheduler and schedule update in 'minutes'
      '''
      logger.debug("rescheduling")
      if not self.__scheduler.empty():
        logger.debug("Reset scheduler")
        for task in self.__scheduler.queue:
          try:
            self.__scheduler.cancel(task)
          except:
            pass
      if self.__scheduler.empty():
        self.__scheduler.enter(minutes * 60, 1, self.__get_updates)
        logger.info("Scheduled check for updates in %d %s", minutes if minutes >= 1 else minutes*60, "minutes" if minutes >= 1 else "seconds" )
        return True

      return False 
開發者ID:manatools,項目名稱:dnfdragora,代碼行數:20,代碼來源:updater.py

示例4: __init__

# 需要導入模塊: import sched [as 別名]
# 或者: from sched import scheduler [as 別名]
def __init__(self, registry, conn, queues, polling=SCHED_POLLING, async_mode=True):
        super().__init__()
        self.registry = registry
        self.conn = conn
        self.polling = polling
        self.async_mode = async_mode

        self._rwlock = RWLock()
        self._delayer = sched.scheduler()
        self._queues = {
            queue_id: rq.Queue(queue_id,
                               connection=self.conn,
                               is_async=self.async_mode)  # noqa: W606
            for queue_id in queues
        }
        self._tasks_events = {}
        self._tasks_jobs = {} 
開發者ID:chaoss,項目名稱:grimoirelab-kingarthur,代碼行數:19,代碼來源:scheduler.py

示例5: _cancel_task

# 需要導入模塊: import sched [as 別名]
# 或者: from sched import scheduler [as 別名]
def _cancel_task(self, task_id):
        event = self._tasks_events.get(task_id, None)

        # The job is in the scheduler
        if event:
            try:
                self._delayer.cancel(event)
                del self._tasks_events[task_id]
                logger.debug("Event found for task %s; canceling it", task_id)
                return
            except ValueError:
                logger.debug("Event not found for task %s; it should be on the queue",
                             task_id)

        # The job is running on a queue
        job_id = self._tasks_jobs[task_id]
        rq.cancel_job(job_id, connection=self.conn)
        logger.debug("Job #%s canceled", job_id)
        del self._tasks_jobs[task_id] 
開發者ID:chaoss,項目名稱:grimoirelab-kingarthur,代碼行數:21,代碼來源:scheduler.py

示例6: __init__

# 需要導入模塊: import sched [as 別名]
# 或者: from sched import scheduler [as 別名]
def __init__(self, server, logfile, screen):
        self.screen = screen
        self.paused = False
        self.seconds = 1.0
        self.sched = sched.scheduler(time.time, time.sleep)

        self.aggregate = False
        self.selected_server = Point()
        self.server_window = None

        if server:
            self.client = DashboardClient(self, server)
            self.mode = self.MODE_SERVER
        else:
            self.client = DashboardLogfile(self, logfile)
            self.mode = self.MODE_LOGREPLAY
        self.client_error = False 
開發者ID:apple,項目名稱:ccs-calendarserver,代碼行數:19,代碼來源:dashview.py

示例7: __init__

# 需要導入模塊: import sched [as 別名]
# 或者: from sched import scheduler [as 別名]
def __init__(self, executor, resolution_seconds=0.1):
        self._executor = executor
        self._resolution_seconds = resolution_seconds

        self._shutting_down = False
        self._shut_down_event = Event()
        self._runner = Thread(target=self._run_scheduler)
        self._scheduler = sched.scheduler(time.time, time.sleep) 
開發者ID:typeintandem,項目名稱:tandem,代碼行數:10,代碼來源:time_scheduler.py

示例8: start

# 需要導入模塊: import sched [as 別名]
# 或者: from sched import scheduler [as 別名]
def start(self):
        """
        Starts this scheduler.

        Until this is called, no tasks will actually be scheduled.
        However the scheduler will still accept schedule requests.
        """
        self._runner.start() 
開發者ID:typeintandem,項目名稱:tandem,代碼行數:10,代碼來源:time_scheduler.py

示例9: stop

# 需要導入模塊: import sched [as 別名]
# 或者: from sched import scheduler [as 別名]
def stop(self):
        """
        Stops this scheduler.

        All remaining pending tasks after this returns will no
        longer be scheduled. This does not wait for all pending
        tasks to be scheduled.
        """
        self._shutting_down = True
        self._shut_down_event.set()
        self._runner.join() 
開發者ID:typeintandem,項目名稱:tandem,代碼行數:13,代碼來源:time_scheduler.py

示例10: __init__

# 需要導入模塊: import sched [as 別名]
# 或者: from sched import scheduler [as 別名]
def __init__(self, connector: CanConnector):
        super().__init__()
        self.connector = connector
        self.scheduler = sched.scheduler(time.time, time.sleep)
        self.events = []
        self.first_run = True
        self.daemon = True 
開發者ID:thingsboard,項目名稱:thingsboard-gateway,代碼行數:9,代碼來源:can_connector.py

示例11: run

# 需要導入模塊: import sched [as 別名]
# 或者: from sched import scheduler [as 別名]
def run(self):
        self.scheduler.run()
        log.info("[%s] Poller stopped", self.connector.get_name()) 
開發者ID:thingsboard,項目名稱:thingsboard-gateway,代碼行數:5,代碼來源:can_connector.py

示例12: stop

# 需要導入模塊: import sched [as 別名]
# 或者: from sched import scheduler [as 別名]
def stop(self):
        log.debug("[%s] Stopping poller", self.connector.get_name())
        for event in self.events:
            self.scheduler.cancel(event) 
開發者ID:thingsboard,項目名稱:thingsboard-gateway,代碼行數:6,代碼來源:can_connector.py

示例13: __poll_and_schedule

# 需要導入模塊: import sched [as 別名]
# 或者: from sched import scheduler [as 別名]
def __poll_and_schedule(self, data, config):
        if self.connector.is_stopped():
            return
        if self.events:
            self.events.pop(0)

        log.debug("[%s] Sending periodic (%f sec) CAN message (arbitration_id=%d, data=%s)",
                  self.connector.get_name(), config["period"], config["nodeId"], data)
        self.connector.send_data_to_bus(data, config, raise_exception=self.first_run)

        event = self.scheduler.enter(config["period"], 1, self.__poll_and_schedule, argument=(data, config))
        self.events.append(event) 
開發者ID:thingsboard,項目名稱:thingsboard-gateway,代碼行數:14,代碼來源:can_connector.py

示例14: __init__

# 需要導入模塊: import sched [as 別名]
# 或者: from sched import scheduler [as 別名]
def __init__(self, profiler_enabled_time_str, output_dir):
    """Constructor.

    Args:
      profiler_enabled_time_str: the value of the config --profiler_enabled_time
      output_dir: log directory to place the profiler data
    """

    self.profiler_enabled_time_str = profiler_enabled_time_str
    self.output_dir = output_dir
    self.exit_event = threading.Event()
    self.scheduler = sched.scheduler(time.time, self._sleep_until_exit) 
開發者ID:tensorflow,項目名稱:benchmarks,代碼行數:14,代碼來源:tensorflow_profiler.py

示例15: __init__

# 需要導入模塊: import sched [as 別名]
# 或者: from sched import scheduler [as 別名]
def __init__(self, output_dir):
    self.process_info_log = open(os.path.join(output_dir, 'process_info.log'),
                                 'w')
    self.scheduler = sched.scheduler(time.time, time.sleep)
    self.process_info = {}
    self.process_info['max_rss'] = 0
    self.process_info['max_vms'] = 0
    self.process_info['max_cpu_percent'] = 0
    self.exit_event = threading.Event()
    self.last_exception = None
    self.start_time = None 
開發者ID:tensorflow,項目名稱:benchmarks,代碼行數:13,代碼來源:process_info_tracker.py


注:本文中的sched.scheduler方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。