本文整理汇总了Python中scheduler.Scheduler.stop方法的典型用法代码示例。如果您正苦于以下问题:Python Scheduler.stop方法的具体用法?Python Scheduler.stop怎么用?Python Scheduler.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scheduler.Scheduler
的用法示例。
在下文中一共展示了Scheduler.stop方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import stop [as 别名]
def run():
s = Scheduler()
s.start()
try:
templates = "%s/views" % os.path.realpath(os.path.dirname(__file__))
bottle.TEMPLATE_PATH.insert(0, templates)
# bottle.debug(True)
bottle.run(host='', port=6060) #, reloader=True)
except KeyboardInterrupt:
pass
s.stop()
示例2: main
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import stop [as 别名]
def main():
global api
root_app = bottle.Bottle()
result = config.validate(validator, copy = True)
if result is False:
print "Config file validation failed"
sys.exit(1)
api = API(app, config, VERSION)
ConfigAPI(api, config)
tellstick = TellstickAPI(api, config, VERSION)
scheduler = Scheduler(config, tellstick)
SchedulerAPI(api, config)
class ConfigWatcher(object):
def notify(self, observable, key):
print "writing"
config.write()
watcher = ConfigWatcher()
config.observe(watcher)
if config['installed'] != VERSION:
api.install()
if config['webroot']:
root_app.mount(config['webroot'], app)
else:
root_app.merge(app)
session_opts = {
'session.type': 'cookie',
'session.validate_key': config['cookieKey'],
'session.auto': True,
}
bottle.run(SessionMiddleware(root_app, session_opts),
host = config['host'],
port = config['port'],
debug = config['debug'],
reloader = False,
server = 'cherrypy')
if scheduler:
scheduler.stop()
# The goal was to have all changes to the config call the watcher
# method which writes to file. Unfortunately subsections wouldn't
# play along, so write to file once we've finished with the service
config.write()
示例3: PortGuardDaemon
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import stop [as 别名]
class PortGuardDaemon(Daemon):
def run(self):
self.sched = Scheduler()
self.server = SimpleXMLRPCServer(("0.0.0.0", 8812),
requestHandler=RequestHandler)
self.server.register_instance(PortGuard(self.sched))
self.sched.start()
try:
self.server.serve_forever()
finally:
self.sched.stop()
示例4: update_indoor
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import stop [as 别名]
update_indoor()
update_outdoor()
update_control()
server_connect()
post_server_data()
get_web_command()
init()
scheduler1 = Scheduler(300, update_outdoor)
scheduler2 = Scheduler(300, update_indoor)
# scheduler3 = Scheduler(30, update_control)
server_scheduler = Scheduler(60, server_connect)
post_server_scheduler = Scheduler(60, post_server_data)
get_web_command_scheduler = Scheduler(0.5, get_web_command)
scheduler1.start()
scheduler2.start()
# scheduler3.start()
server_scheduler.start()
post_server_scheduler.start()
get_web_command_scheduler.start()
if __name__ == '__main__':
app.run('0.0.0.0', '8020', threaded=True)
scheduler1.stop()
scheduler2.stop()
server_scheduler.stop()
get_web_command_scheduler.stop()
post_server_scheduler.stop()
# scheduler3.stop()
示例5: SocketController
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import stop [as 别名]
class SocketController(object):
state = {
1: False,
2: False,
3: False,
4: False,
}
action_dict = {
'1': ('1-on', '1-off'),
'2': ('2-on', '2-off'),
'3': ('3-on', '3-off'),
'4': ('4-on', '4-off'),
}
def __init__(self, config):
if getattr(config, 'ICAL_URL', None):
self.scheduler = Scheduler(config.ICAL_URL,
self._switch_by_code,
self.action_dict,
polling_interval=config.POLLING_INTERVAL)
else:
self.scheduler = None
def start(self):
pimote.init()
pimote.switch('all-off')
if self.scheduler:
self.scheduler.start()
def stop(self):
if self.scheduler:
self.scheduler.stop()
pimote.term()
def _switch_by_code(self, code):
getattr(self, 'switch_' + code.replace("-", "_"))()
def switch_1_on(self):
if pimote.switch('1-on'):
self.state[1] = True
def switch_1_off(self):
if pimote.switch('1-off'):
self.state[1] = False
def switch_2_on(self):
if pimote.switch('2-on'):
self.state[2] = True
def switch_2_off(self):
if pimote.switch('2-off'):
self.state[2] = False
def switch_3_on(self):
if pimote.switch('3-on'):
self.state[3] = True
def switch_3_off(self):
if pimote.switch('3-off'):
self.state[3] = False
def switch_4_on(self):
if pimote.switch('4-on'):
self.state[4] = True
def switch_4_off(self):
if pimote.switch('4-off'):
self.state[4] = False
def switch_all_on(self):
if pimote.switch('all-on'):
self.state[1] = True
self.state[2] = True
self.state[3] = True
self.state[4] = True
def switch_all_off(self):
if pimote.switch('all-off'):
self.state[1] = False
self.state[2] = False
self.state[3] = False
self.state[4] = False
示例6: Server
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import stop [as 别名]
#.........这里部分代码省略.........
'/': os.path.normpath(www_path),
}, cache=False)
@self.app.route('/', methods=['GET'])
def index_get():
with open(os.path.join(www_path, 'index.html'), 'r') as fd:
return fd.read()
def _setup_all(self):
self._setup_app()
self._setup_conf()
self._setup_log()
self._setup_db()
self._setup_handlers()
self._setup_static_handler()
def _run_wsgi(self):
import cherrypy.wsgiserver
logger.info('Starting server...')
server = cherrypy.wsgiserver.CherryPyWSGIServer(
(self.bind_addr, self.port), self.app)
try:
server.start()
except (KeyboardInterrupt, SystemExit):
pass
except:
logger.exception('Server error occurred')
raise
finally:
signal.signal(signal.SIGINT, signal.SIG_IGN)
self.interrupt = True
self._stop_scheduler()
logger.info('Stopping server...')
server.stop()
self._close_db()
def _run_wsgi_debug(self):
logger.info('Starting debug server...')
# App.run server uses werkzeug logger
werkzeug_logger = logging.getLogger('werkzeug')
werkzeug_logger.setLevel(self.log_level)
werkzeug_logger.addHandler(self.log_handler)
try:
self.app.run(host=self.bind_addr, port=self.port, threaded=True)
except (KeyboardInterrupt, SystemExit):
pass
except:
logger.exception('Server error occurred')
raise
finally:
signal.signal(signal.SIGINT, signal.SIG_IGN)
self.interrupt = True
self._stop_scheduler()
# Possible data loss here db closing before debug server
self._close_db()
logger.info('Stopping server...')
def _run_server(self):
if self.debug:
self._run_wsgi_debug()
else:
self._run_wsgi()