当前位置: 首页>>代码示例>>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;未经允许,请勿转载。