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


Python reactor.suggestThreadPoolSize方法代碼示例

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


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

示例1: __init__

# 需要導入模塊: from twisted.internet import reactor [as 別名]
# 或者: from twisted.internet.reactor import suggestThreadPoolSize [as 別名]
def __init__(self,
                 data_router,
                 loglevel='INFO',
                 logfile=None,
                 num_threads=1,
                 token=None,
                 cors_origins=None,
                 testing=False,
                 default_config_path=None):

        self._configure_logging(loglevel, logfile)

        self.default_model_config = self._load_default_config(
            default_config_path)

        self.data_router = data_router
        self._testing = testing
        self.cors_origins = cors_origins if cors_origins else ["*"]
        self.access_token = token
        reactor.suggestThreadPoolSize(num_threads * 5) 
開發者ID:weizhenzhao,項目名稱:rasa_nlu,代碼行數:22,代碼來源:server.py

示例2: main

# 需要導入模塊: from twisted.internet import reactor [as 別名]
# 或者: from twisted.internet.reactor import suggestThreadPoolSize [as 別名]
def main():
    namespace = _get_env_namespace()
    if namespace is None:
        namespace = _get_sa_namespace()
    if namespace is None:
        namespace = _guess_namespace()
    if namespace is None:
        print("\nERROR: Failed to determine namespace")
        print("Enable serviceaccount access via")
        print("  automountServiceAccountToken: true")
        print("in your Deployment")
        print("or set the TELEPRESENCE_CONTAINER_NAMESPACE env var")
        print("directly or using the Downward API.\n")
        exit("ERROR: Failed to determine namespace")
    print("Pod's namespace is {!r}".format(namespace))
    telepresence_nameserver = os.environ.get("TELEPRESENCE_NAMESERVER")
    reactor.suggestThreadPoolSize(50)
    periodic.setup(reactor)
    print("Listening...")
    listen(resolver.LocalResolver(telepresence_nameserver, namespace)) 
開發者ID:telepresenceio,項目名稱:telepresence,代碼行數:22,代碼來源:forwarder.py

示例3: __init__

# 需要導入模塊: from twisted.internet import reactor [as 別名]
# 或者: from twisted.internet.reactor import suggestThreadPoolSize [as 別名]
def __init__(self,
                 data_router,
                 loglevel='INFO',
                 logfile=None,
                 num_threads=1,
                 token=None,
                 cors_origins=None,
                 testing=False,
                 default_config_path=None):

        self._configure_logging(loglevel, logfile)

        self.default_model_config = self._load_default_config(
                default_config_path)

        self.data_router = data_router
        self._testing = testing
        self.cors_origins = cors_origins if cors_origins else ["*"]
        self.access_token = token
        reactor.suggestThreadPoolSize(num_threads * 5) 
開發者ID:crownpku,項目名稱:Rasa_NLU_Chi,代碼行數:22,代碼來源:server.py

示例4: main

# 需要導入模塊: from twisted.internet import reactor [as 別名]
# 或者: from twisted.internet.reactor import suggestThreadPoolSize [as 別名]
def main(argv=None):
    """ start up twisted reactor """
    parser = argparse.ArgumentParser(description='VMWare metrics exporter for Prometheus')
    parser.add_argument('-c', '--config', dest='config_file',
                        default=None, help="configuration file")
    parser.add_argument('-p', '--port', dest='port', type=int,
                        default=9272, help="HTTP port to expose metrics")
    parser.add_argument('-l', '--loglevel', dest='loglevel',
                        default="INFO", help="Set application loglevel INFO, DEBUG")

    args = parser.parse_args(argv or sys.argv[1:])

    numeric_level = getattr(logging, args.loglevel.upper(), None)
    if not isinstance(numeric_level, int):
        raise ValueError("Invalid log level: {level}".format(level=args.loglevel))
    logging.basicConfig(level=numeric_level, format='%(asctime)s %(levelname)s:%(message)s')

    reactor.suggestThreadPoolSize(25)

    factory = Site(registerEndpoints(args))
    logging.info("Starting web server on port {port}".format(port=args.port))
    endpoint = endpoints.TCP4ServerEndpoint(reactor, args.port)
    endpoint.listen(factory)
    reactor.run() 
開發者ID:pryorda,項目名稱:vmware_exporter,代碼行數:26,代碼來源:vmware_exporter.py

示例5: test_suggestThreadPoolSize

# 需要導入模塊: from twisted.internet import reactor [as 別名]
# 或者: from twisted.internet.reactor import suggestThreadPoolSize [as 別名]
def test_suggestThreadPoolSize(self):
        """
        Try to change maximum number of threads.
        """
        reactor.suggestThreadPoolSize(34)
        self.assertEqual(reactor.threadpool.max, 34)
        reactor.suggestThreadPoolSize(4)
        self.assertEqual(reactor.threadpool.max, 4) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:10,代碼來源:test_threads.py

示例6: setUp

# 需要導入模塊: from twisted.internet import reactor [as 別名]
# 或者: from twisted.internet.reactor import suggestThreadPoolSize [as 別名]
def setUp(self):
        reactor.suggestThreadPoolSize(8) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:4,代碼來源:test_threads.py

示例7: tearDown

# 需要導入模塊: from twisted.internet import reactor [as 別名]
# 或者: from twisted.internet.reactor import suggestThreadPoolSize [as 別名]
def tearDown(self):
        reactor.suggestThreadPoolSize(0) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:4,代碼來源:test_threads.py

示例8: run

# 需要導入模塊: from twisted.internet import reactor [as 別名]
# 或者: from twisted.internet.reactor import suggestThreadPoolSize [as 別名]
def run(self):
        """Start the services and run the reactor"""
        reactor.suggestThreadPoolSize(constants.THREAD_POOL_SIZE)
        self.startService()
        reactor.run() 
開發者ID:mozilla-services,項目名稱:autopush,代碼行數:7,代碼來源:main.py

示例9: start_loop

# 需要導入模塊: from twisted.internet import reactor [as 別名]
# 或者: from twisted.internet.reactor import suggestThreadPoolSize [as 別名]
def start_loop(agents):
    reactor.suggestThreadPoolSize(30)
    for agent in agents:
        agent.update_ams(agent.ams)
        agent.on_start()
        ILP = reactor.listenTCP(agent.aid.port, agent.agentInstance)
        agent.ILP = ILP
    reactor.run() 
開發者ID:grei-ufc,項目名稱:pade,代碼行數:10,代碼來源:utility.py

示例10: test_suggestThreadPoolSize

# 需要導入模塊: from twisted.internet import reactor [as 別名]
# 或者: from twisted.internet.reactor import suggestThreadPoolSize [as 別名]
def test_suggestThreadPoolSize(self):
        """
        Try to change maximum number of threads.
        """
        reactor.suggestThreadPoolSize(34)
        self.assertEquals(reactor.threadpool.max, 34)
        reactor.suggestThreadPoolSize(4)
        self.assertEquals(reactor.threadpool.max, 4) 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:10,代碼來源:test_threads.py

示例11: do_cleanThreads

# 需要導入模塊: from twisted.internet import reactor [as 別名]
# 或者: from twisted.internet.reactor import suggestThreadPoolSize [as 別名]
def do_cleanThreads(cls):
        from twisted.internet import reactor
        if interfaces.IReactorThreads.providedBy(reactor):
            reactor.suggestThreadPoolSize(0)
            if hasattr(reactor, 'threadpool') and reactor.threadpool:
                reactor.threadpool.stop()
                reactor.threadpool = None
                # *Put it back* and *start it up again*.  The
                # reactor's threadpool is *private*: we cannot just
                # rape it and walk away.
                reactor.threadpool = threadpool.ThreadPool(0, 10)
                reactor.threadpool.start() 
開發者ID:kenorb-contrib,項目名稱:BitTorrent,代碼行數:14,代碼來源:util.py

示例12: testSuggestThreadPoolSize

# 需要導入模塊: from twisted.internet import reactor [as 別名]
# 或者: from twisted.internet.reactor import suggestThreadPoolSize [as 別名]
def testSuggestThreadPoolSize(self):
        # XXX Uh, how about some asserts?
        reactor.suggestThreadPoolSize(34)
        reactor.suggestThreadPoolSize(4) 
開發者ID:kenorb-contrib,項目名稱:BitTorrent,代碼行數:6,代碼來源:test_threads.py

示例13: start_reactor

# 需要導入模塊: from twisted.internet import reactor [as 別名]
# 或者: from twisted.internet.reactor import suggestThreadPoolSize [as 別名]
def start_reactor(self):
        reactor.callWhenRunning(
            lambda: self.log.info('twisted-reactor-started'))

        reactor.addSystemEventTrigger('before', 'shutdown',
                                      self.shutdown_components)
        reactor.suggestThreadPoolSize(30)
        reactor.run() 
開發者ID:opencord,項目名稱:voltha,代碼行數:10,代碼來源:main.py

示例14: prepare_twisted_service

# 需要導入模塊: from twisted.internet import reactor [as 別名]
# 或者: from twisted.internet.reactor import suggestThreadPoolSize [as 別名]
def prepare_twisted_service(handler, reactor_thread_size=100):
    """prepare twsited service
    """
    LOG.info('Prepare twisted services')

    LOG.info('Get peer configuration')
    for conf_key in CONF.bgp.running_config:
        LOG.info('---%s = %s', conf_key, CONF.bgp.running_config[conf_key])

    # init handler
    handler.init()

    LOG.info('Create BGPPeering twsited instance')
    afi_safi_list = [bgp_cons.AFI_SAFI_STR_DICT[afi_safi] for afi_safi in CONF.bgp.running_config['afi_safi']]
    CONF.bgp.running_config['afi_safi'] = afi_safi_list
    CONF.bgp.running_config['capability']['local']['afi_safi'] = afi_safi_list
    bgp_peering = BGPPeering(
        myasn=CONF.bgp.running_config['local_as'],
        myaddr=CONF.bgp.running_config['local_addr'],
        peerasn=CONF.bgp.running_config['remote_as'],
        peeraddr=CONF.bgp.running_config['remote_addr'],
        afisafi=CONF.bgp.running_config['afi_safi'],
        md5=CONF.bgp.running_config['md5'],
        handler=handler
    )
    CONF.bgp.running_config['factory'] = bgp_peering

    # Starting api server
    LOG.info("Prepare RESTAPI service")
    LOG.info("reactor_thread_size = %s", reactor_thread_size)
    reactor.suggestThreadPoolSize(reactor_thread_size)
    resource = WSGIResource(reactor, reactor.getThreadPool(), app)
    site = Site(resource)
    try:
        reactor.listenTCP(CONF.rest.bind_port, site, interface=CONF.rest.bind_host)
        LOG.info("serving RESTAPI on http://%s:%s", CONF.rest.bind_host, CONF.rest.bind_port)
    except Exception as e:
        LOG.error(e, exc_info=True)
        sys.exit()

    LOG.info('Starting BGPPeering twsited instance')
    bgp_peering.automatic_start()

    reactor.run() 
開發者ID:smartbgp,項目名稱:yabgp,代碼行數:46,代碼來源:__init__.py


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