当前位置: 首页>>代码示例>>Python>>正文


Python internet.TimerService类代码示例

本文整理汇总了Python中twisted.application.internet.TimerService的典型用法代码示例。如果您正苦于以下问题:Python TimerService类的具体用法?Python TimerService怎么用?Python TimerService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TimerService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: application

def application(config):
	app = Application("Scrapyd")
	http_port = config.getint('http_port', 6800)
	
	portal = Portal(PublicHTMLRealm(config, app), [FilePasswordDB(str(config.get('passwd', '')))])
	credentialFactory = DigestCredentialFactory("md5", "Go away")
	
	poller = QueuePoller(config)
	eggstorage = FilesystemEggStorage(config)
	scheduler = SpiderScheduler(config)
	environment = Environment(config)
	
	app.setComponent(IPoller, poller)
	app.setComponent(IEggStorage, eggstorage)
	app.setComponent(ISpiderScheduler, scheduler)
	app.setComponent(IEnvironment, environment)
	
	launcher = Launcher(config, app)
	timer = TimerService(5, poller.poll)
	webservice = TCPServer(http_port, server.Site(HTTPAuthSessionWrapper(portal, [credentialFactory])))
	log.msg("Scrapyd web console available at http://localhost:%s/" % http_port)
	
	launcher.setServiceParent(app)
	timer.setServiceParent(app)
	webservice.setServiceParent(app)
	
	return app
开发者ID:trunk,项目名称:littlespider,代码行数:27,代码来源:app.py

示例2: stopService

 def stopService(self):
     """
     Stop this service. This will release buckets partitions it holds
     """
     TimerService.stopService(self)
     if self.kz_partition.acquired:
         return self.kz_partition.finish()
开发者ID:MariaAbrahms,项目名称:otter,代码行数:7,代码来源:scheduler.py

示例3: __init__

 def __init__(self, kz_client, interval, partitioner_path, buckets,
              time_boundary, log, got_buckets,
              clock=None):
     """
     :param log: a bound log
     :param kz_client: txKazoo client
     :param partitioner_path: ZooKeeper path, used for partitioning
     :param buckets: iterable of buckets to distribute between
         nodes. Ideally there should be at least as many elements as nodes
         taking part in this partitioner. This should be a sequence of str.
     :param time_boundary: time to wait for partitioning to stabilize.
     :param got_buckets: Callable which will be called with a list of
         buckets when buckets have been allocated to this node.
     :param clock: clock to use for checking the buckets on an interval.
     """
     MultiService.__init__(self)
     self.kz_client = kz_client
     self.partitioner_path = partitioner_path
     self.buckets = buckets
     self.log = log
     self.got_buckets = got_buckets
     self.time_boundary = time_boundary
     ts = TimerService(interval, self.check_partition)
     ts.setServiceParent(self)
     ts.clock = clock
     self._old_buckets = []
开发者ID:rackerlabs,项目名称:otter,代码行数:26,代码来源:zkpartitioner.py

示例4: __init__

    def __init__(self, basedir="."):
        node.Node.__init__(self, basedir)
        self.started_timestamp = time.time()
        self.logSource="Client"
        self.DEFAULT_ENCODING_PARAMETERS = self.DEFAULT_ENCODING_PARAMETERS.copy()
        self.init_introducer_client()
        self.init_stats_provider()
        self.init_secrets()
        self.init_storage()
        self.init_control()
        self.helper = None
        if self.get_config("helper", "enabled", False, boolean=True):
            self.init_helper()
        self._key_generator = KeyGenerator()
        key_gen_furl = self.get_config("client", "key_generator.furl", None)
        if key_gen_furl:
            self.init_key_gen(key_gen_furl)
        self.init_client()
        # ControlServer and Helper are attached after Tub startup
        self.init_ftp_server()
        self.init_sftp_server()

        hotline_file = os.path.join(self.basedir,
                                    self.SUICIDE_PREVENTION_HOTLINE_FILE)
        if os.path.exists(hotline_file):
            age = time.time() - os.stat(hotline_file)[stat.ST_MTIME]
            self.log("hotline file noticed (%ds old), starting timer" % age)
            hotline = TimerService(1.0, self._check_hotline, hotline_file)
            hotline.setServiceParent(self)

        # this needs to happen last, so it can use getServiceNamed() to
        # acquire references to StorageServer and other web-statusable things
        webport = self.get_config("node", "web.port", None)
        if webport:
            self.init_web(webport) # strports string
开发者ID:drewp,项目名称:tahoe-lafs,代码行数:35,代码来源:client.py

示例5: application

def application(config):
    app = Application("Scrapyd")
    http_port = config.getint('http_port', 6800)
    bind_address = config.get('bind_address', '0.0.0.0')

    poller = QueuePoller(config)
    eggstorage = FilesystemEggStorage(config)
    scheduler = SpiderScheduler(config)
    environment = Environment(config)

    app.setComponent(IPoller, poller)
    app.setComponent(IEggStorage, eggstorage)
    app.setComponent(ISpiderScheduler, scheduler)
    app.setComponent(IEnvironment, environment)

    laupath = config.get('launcher', 'scrapyd.launcher.Launcher')
    laucls = load_object(laupath)
    launcher = laucls(config, app)

    timer = TimerService(5, poller.poll)
    webservice = TCPServer(http_port, server.Site(Root(config, app)), interface=bind_address)
    log.msg("Scrapyd web console available at http://%s:%s/" % (bind_address, http_port))

    launcher.setServiceParent(app)
    timer.setServiceParent(app)
    webservice.setServiceParent(app)

    return app
开发者ID:Root-nix,项目名称:scrapy,代码行数:28,代码来源:app.py

示例6: application

def application(config):
	app = Application("Scrapyd")
	http_port = config.getint('http_port', 6800)
	
	poller = QueuePoller(config)
	eggstorage = FilesystemEggStorage(config)
	scheduler = SpiderScheduler(config)
	environment = Environment(config)
	app.setComponent(IPoller, poller)
	app.setComponent(IEggStorage, eggstorage)
	app.setComponent(ISpiderScheduler, scheduler)
	app.setComponent(IEnvironment, environment)
	
	launcher = Launcher(config, app)
	timer = TimerService(5, poller.poll)
	root = Root(config, app)
	root = configRoot(root, config)
	
	webservice = TCPServer(http_port, server.Site(root))
	log.msg("Scrapyd web console available at http://localhost:%s/" % http_port)

	launcher.setServiceParent(app)
	timer.setServiceParent(app)
	webservice.setServiceParent(app)

	return app
开发者ID:huangpanxx,项目名称:POAS,代码行数:26,代码来源:app.py

示例7: setup_selfheal_service

def setup_selfheal_service(clock, config, dispatcher, health_checker, log):
    """
    Setup selfheal timer service and return it.

    :param clock: :obj:`IReactorTime` provider
    :param dict config: Configuration dict containing selfheal info
    :param dispatcher: Effect dispatcher
    :param health_checker: ``HealthChecker`` object where SelfHeal's health
        check will be added
    :param log: :obj:`BoundLog` logger used by service

    :return: selfheal service or None if relevant config is not found
    :rtype: :obj:`IService`
    """
    if "selfheal" not in config:
        return None
    interval = get_in(["selfheal", "interval"], config, no_default=True)
    selfheal = SelfHeal(clock, dispatcher, config_value, interval, log)
    func, lock = zk.locked_logged_func(
        dispatcher, "/selfheallock", log, "selfheal-lock-acquired",
        selfheal.setup)
    health_checker.checks["selfheal"] = zk.create_health_check(lock)
    sh_timer = TimerService(interval, func)
    sh_timer.clock = clock
    return sh_timer
开发者ID:rackerlabs,项目名称:otter,代码行数:25,代码来源:api.py

示例8: get_application

def get_application(config):
    app = Application('Scrapyd')
    http_port = config.getint('http_port', 6800)
    bind_address = config.get('bind_address', '0.0.0.0')
    poll_interval = config.getfloat('poll_interval', 5)

    poller = QueuePoller(config)
    eggstorage = FilesystemEggStorage(config)
    scheduler = SpiderScheduler(config)
    environment = Environment(config)

    app.setComponent(IPoller, poller)
    app.setComponent(IEggStorage, eggstorage)
    app.setComponent(ISpiderScheduler, scheduler)
    app.setComponent(IEnvironment, environment)

    laupath = config.get('launcher', 'scrapyd_mongodb.launcher.Launcher')
    laucls = load_object(laupath)
    launcher = laucls(config, app)

    timer = TimerService(poll_interval, poller.poll)
    webservice = TCPServer(
        http_port, server.Site(Root(config, app)),
        interface=bind_address)

    log.msg('http://%(bind_address)s:%(http_port)s/' % {'bind_address':bind_address, 'http_port':http_port})

    launcher.setServiceParent(app)
    timer.setServiceParent(app)
    webservice.setServiceParent(app)

    return app
开发者ID:Tiago-Lira,项目名称:scrapyd-mongodb,代码行数:32,代码来源:application.py

示例9: application

def application(config, components=interfaces):
    app = Application("Scrapyd")
    http_port = config.getint('http_port', 6800)
    bind_address = config.get('bind_address', '0.0.0.0')

    for interface, key in interfaces:
        path = config.get(key)
        cls = load_object(path)
        component = cls(config)
        app.setComponent(interface, component)
    poller = component
        
    laupath = config.get('launcher', 'scrapyd.launcher.Launcher')
    laucls = load_object(laupath) 
    launcher = laucls(config, app)

    poll_every = config.getint("poll_every", 5)
    timer = TimerService(poll_every, poller.poll)
    
    webservice = TCPServer(http_port, server.Site(Root(config, app)), interface=bind_address)
    log.msg(format="Scrapyd web console available at http://%(bind_address)s:%(http_port)s/",
            bind_address=bind_address, http_port=http_port)

    launcher.setServiceParent(app)
    timer.setServiceParent(app)
    webservice.setServiceParent(app)

    return app
开发者ID:llonchj,项目名称:scrapyd,代码行数:28,代码来源:app.py

示例10: application

def application(config):
    app = Application("Scrapyd")
    http_port = int(environ.get('PORT', config.getint('http_port', 6800)))
    config.cp.set('scrapyd', 'database_url', environ.get('DATABASE_URL'))

    poller = Psycopg2QueuePoller(config)
    eggstorage = FilesystemEggStorage(config)
    scheduler = Psycopg2SpiderScheduler(config)
    environment = Environment(config)

    app.setComponent(IPoller, poller)
    app.setComponent(IEggStorage, eggstorage)
    app.setComponent(ISpiderScheduler, scheduler)
    app.setComponent(IEnvironment, environment)

    launcher = Launcher(config, app)
    timer = TimerService(5, poller.poll)
    webservice = TCPServer(http_port, server.Site(Root(config, app)))
    log.msg("Scrapyd web console available at http://localhost:%s/ (HEROKU)"
        % http_port)

    launcher.setServiceParent(app)
    timer.setServiceParent(app)
    webservice.setServiceParent(app)

    return app
开发者ID:kayawaffles,项目名称:scrapy-heroku,代码行数:26,代码来源:app.py

示例11: startService

 def startService(self):
     """
     Start this service. This will start buckets partitioning
     """
     self.kz_partition = self.kz_client.SetPartitioner(
         self.zk_partition_path, set=set(self.buckets),
         time_boundary=self.time_boundary)
     TimerService.startService(self)
开发者ID:MariaAbrahms,项目名称:otter,代码行数:8,代码来源:scheduler.py

示例12: __init__

 def __init__(self, reactor):
     MultiService.__init__(self)
     self._deployment_state = DeploymentState()
     timer = TimerService(1, self._wipe_expired)
     timer.clock = reactor
     timer.setServiceParent(self)
     self._information_wipers = pmap()
     self._clock = reactor
开发者ID:332054781,项目名称:flocker,代码行数:8,代码来源:_clusterstate.py

示例13: __init__

 def __init__(self, poller=None, step=300):
     """
     """
     if poller is None:
         raise RuntimeError('poller cannot be None')
     if not issubclass(type(poller), IPoll):
         raise TypeError('poller privided is not a subclass of IPoll')
     self._poller = poller
     TimerService.__init__(self, step=step, callable=self._poller.poll)
开发者ID:flihp,项目名称:twobit-git-poller,代码行数:9,代码来源:githuborgrepopollerservice.py

示例14: __init__

 def __init__(self, poller=None, step=60*5):
     """ The magic here is calling the TimerService constructor (old
         style class) to set the polling interval and specify the polling
         function.
     """
     if poller is None:
         raise RuntimeError('poller cannot be None')
     if not issubclass(type(poller), IPoll):
         raise TypeError('poller provided is not a subclass of IPoll');
     self._poller = poller
     TimerService.__init__(self, step=step, callable=self._poller.poll)
开发者ID:flihp,项目名称:twobit-git-poller,代码行数:11,代码来源:gitpollerservice.py

示例15: __init__

 def __init__(self, reactor, interval, k8s, namespace, router):
     TimerService.__init__(
         self,
         interval,
         divert_errors_to_log(self._check_once, u"router-update"),
         k8s,
         namespace,
     )
     # This attribute controls the the reactor used by TimerService to set
     # up the LoopingCall.
     self.clock = reactor
     self._router = router
开发者ID:LeastAuthority,项目名称:leastauthority.com,代码行数:12,代码来源:_router.py


注:本文中的twisted.application.internet.TimerService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。