• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python data.create_store函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: create_store

 def create_store(cls, address, namespace=None, pool_size=2, **kw):
     if cls.redis_py_parser:
         kw['parser_class'] = redis_parser(True)
     if not namespace:
         namespace = cls.randomkey(6).lower()
     return create_store(address, namespace=namespace,
                         pool_size=pool_size, **kw)
开发者ID:wilddom,项目名称:pulsar,代码行数:7,代码来源:test_pulsards.py


示例2: setup

 def setup(self, environ):
     cfg = environ['pulsar.cfg']
     self.store = create_store(cfg.data_store)
     pubsub = self.store.pubsub()
     return WsgiHandler([Router('/', get=self.home_page),
                         WebSocket('/message',
                                   TweetsWsHandler(pubsub, self.channel))])
开发者ID:JinsongBian,项目名称:pulsar,代码行数:7,代码来源:manage.py


示例3: __init__

 def __init__(self, app, name, url):
     super().__init__(app, name, url)
     if app.green_pool:
         self._wait = app.green_pool.wait
         self.client = create_store(url).client()
     else:
         import redis
         self.client = redis.StrictRedis.from_url(url)
开发者ID:quantmind,项目名称:lux,代码行数:8,代码来源:cache.py


示例4: monitor_start

    def monitor_start(self, monitor):
        '''When the monitor starts load all test classes into the queue'''
        # Create a datastore for this test suite
        if not self.cfg.task_backend:
            server = PulsarDS(bind='127.0.0.1:0', workers=0,
                              key_value_save=[],
                              name='%s_store' % self.name)
            yield server()
            address = 'pulsar://%s:%s' % server.cfg.addresses[0]
        else:
            address = self.cfg.task_backend

        store = create_store(address, pool_size=2, loop=monitor._loop)
        self.get_backend(store)
        loader = self.loader
        tags = self.cfg.labels
        exclude_tags = self.cfg.exclude_labels
        if self.cfg.show_leaks:
            show = show_leaks if self.cfg.show_leaks == 1 else hide_leaks
            self.cfg.set('when_exit', show)
            arbiter = pulsar.arbiter()
            arbiter.cfg.set('when_exit', show)
        try:
            tests = []
            loader.runner.on_start()
            for tag, testcls in loader.testclasses(tags, exclude_tags):
                suite = loader.runner.loadTestsFromTestCase(testcls)
                if suite and suite._tests:
                    tests.append((tag, testcls))
            self._time_start = None
            if tests:
                self.logger.info('loading %s test classes', len(tests))
                monitor.cfg.set('workers', min(self.cfg.workers, len(tests)))
                self._time_start = default_timer()
                queued = []
                self._tests_done = set()
                self._tests_queued = None
                #
                # Bind to the task_done event
                self.backend.bind_event('task_done',
                                        partial(self._test_done, monitor))
                for tag, testcls in tests:
                    r = self.backend.queue_task('test', testcls=testcls,
                                                tag=tag)
                    queued.append(r)
                queued = yield multi_async(queued)
                self.logger.debug('loaded %s test classes', len(tests))
                self._tests_queued = set(queued)
                yield self._test_done(monitor)
            else:   # pragma    nocover
                raise ExitTest('Could not find any tests.')
        except ExitTest as e:   # pragma    nocover
            monitor.stream.writeln(str(e))
            monitor.arbiter.stop()
        except Exception:   # pragma    nocover
            monitor.logger.critical('Error occurred while starting tests',
                                    exc_info=True)
            monitor._loop.call_soon(self._exit, 3)
开发者ID:JinsongBian,项目名称:pulsar,代码行数:58,代码来源:__init__.py


示例5: on_loaded

 def on_loaded(self, app):
     '''Once the application has loaded, create the pub/sub
     handler used to publish messages to channels as
     well as subscribe to channels
     '''
     pubsub_store = app.config['PUBSUB_STORE']
     if pubsub_store:
         self.pubsub_store = create_store(pubsub_store)
         self.websocket.pubsub = self.pubsub_store.pubsub()
开发者ID:victor3rc,项目名称:lux,代码行数:9,代码来源:__init__.py


示例6: __init__

 def __init__(self, app, scheme, url):
     super().__init__(app, scheme, url)
     if app.green_pool:
         from pulsar.apps.greenio import wait
         self._wait = wait
         self.client = create_store(url).client()
     else:
         import redis
         self.client = redis.StrictRedis.from_url(url)
开发者ID:victor3rc,项目名称:lux,代码行数:9,代码来源:cache.py


示例7: __init__

 def __init__(self, cfg, logger=None, app=None, **kw):
     self.store = create_store(cfg.data_store)
     self.cfg = cfg
     self.app = app
     self.green_pool = getattr(app, 'green_pool', GreenPool())
     self.logger = logger or logging.getLogger('pulsar.queue')
     self._closing = False
     self._pubsub = PubSub(self)
     self.logger.debug('created %s', self)
开发者ID:pvanderlinden,项目名称:pulsar-queue,代码行数:9,代码来源:producer.py


示例8: create_database

 def create_database(self, dbname=None, **kw):
     dbname = dbname or self.database
     store = create_store(self.dns, database='postgres', loop=self._loop)
     conn = store.sql_engine.connect()
     # when creating a database the connection must not be in a transaction
     conn.execute("commit")
     conn.execute("create database %s" % dbname)
     conn.close()
     return dbname
开发者ID:JinsongBian,项目名称:pulsar,代码行数:9,代码来源:postgresql.py


示例9: get_pubsub

 def get_pubsub(self, websocket):
     if not self._store:
         cfg = websocket.cfg
         self._store = create_store(cfg.data_store, namespace='game_')
         self._client = self._store.client()
         self._pubsub = self._store.pubsub()
         gameserver = '%s:gameserver' % cfg.exc_id
         gameuser = '%s:gameuser' % cfg.exc_id
         yield from self._pubsub.subscribe(gameserver, gameuser)
开发者ID:Faulik,项目名称:jumpdie-backend,代码行数:9,代码来源:views.py


示例10: get_pubsub

 def get_pubsub(self, websocket):
     if not self._store:
         cfg = websocket.cfg
         self._store = create_store(cfg.data_store)
         self._client = self._store.client()
         self._pubsub = self._store.pubsub()
         webchat = '%s:webchat' % cfg.exc_id
         chatuser = '%s:chatuser' % cfg.exc_id
         yield from self._pubsub.subscribe(webchat, chatuser)
     return self._pubsub
开发者ID:Faulik,项目名称:jumpdie-backend,代码行数:10,代码来源:views_new.py


示例11: get_pubsub

 def get_pubsub(self, websocket):
     '''Create the pubsub handler if not already available'''
     if not self._store:
         cfg = websocket.cfg
         self._store = create_store(cfg.data_store)
         self._client = self._store.client()
         self._pubsub = self._store.pubsub()
         webchat = '%s:webchat' % cfg.exc_id
         chatuser = '%s:chatuser' % cfg.exc_id
         self._pubsub.subscribe(webchat, chatuser)
     return self._pubsub
开发者ID:JinsongBian,项目名称:pulsar,代码行数:11,代码来源:views.py


示例12: start_store

async def start_store(app, url, workers=0, **kw):
    '''Equivalent to :func:`.create_store` for most cases excepts when the
    ``url`` is for a pulsar store not yet started.
    In this case, a :class:`.PulsarDS` is started.
    '''
    store = create_store(url, **kw)
    if store.name == 'pulsar':
        client = store.client()
        try:
            await client.ping()
        except ConnectionRefusedError:
            host = localhost(store._host)
            if not host:
                raise
            cfg = await send('arbiter', 'run', start_pulsar_ds,
                             host, workers)
            store._host = cfg.addresses[0]
            dns = store._buildurl()
            store = create_store(dns, **kw)
    app.cfg.set('data_store', store.dns)
开发者ID:juanignaciocatalano,项目名称:pulsar,代码行数:20,代码来源:startds.py


示例13: delete_database

 def delete_database(self, dbname=None):
     # make sure no connections are opened
     self.sql_engine.dispose()
     dbname = dbname or self.database
     # switch to postgres database
     store = create_store(self.dns, database='postgres', loop=self._loop)
     conn = store.sql_engine.connect()
     conn.execute("commit")
     conn.execute("drop database %s" % dbname)
     conn.close()
     return dbname
开发者ID:JinsongBian,项目名称:pulsar,代码行数:11,代码来源:postgresql.py


示例14: start_store

 def start_store(url, workers=0, **kw):
     '''Equivalent to :func:`.create_store` for most cases excepts when the
     ``url`` is for a pulsar store not yet started.
     In this case, a :class:`.PulsarDS` is started.
     '''
     store = create_store(url, **kw)
     if store.name == 'pulsar':
         client = store.client()
         try:
             yield client.ping()
         except pulsar.ConnectionRefusedError:
             host = localhost(store._host)
             if not host:
                 raise
             cfg = yield send('arbiter', 'run', start_pulsar_ds,
                              host, workers)
             store._host = cfg.addresses[0]
             dns = store._buildurl()
             store = create_store(dns, **kw)
     coroutine_return(store)
开发者ID:JinsongBian,项目名称:pulsar,代码行数:20,代码来源:startds.py


示例15: check_redis

def check_redis():
    '''Check if redis server is available at the address specified
    by the :ref:`redis server <setting-redis_server>` config value.

    :rtype: boolean
    '''
    addr = get_actor().cfg.get('redis_server')
    sync_store = create_store(addr, loop=new_event_loop())
    try:
        sync_store.client().ping()
        return True
    except Exception:
        return False
开发者ID:Ghost-script,项目名称:dyno-chat,代码行数:13,代码来源:utils.py


示例16: _autodiscover

    def _autodiscover(self, binds):
        # Setup mdoels and engines
        if not binds:
            binds = {}
        elif isinstance(binds, str):
            binds = {'default': binds}
        if binds and 'default' not in binds:
            raise ImproperlyConfigured('default datastore not specified')

        self.metadata = MetaData()
        self._engines = {}
        self._nosql_engines = {}
        self._declarative_register = {}
        self.binds = {}
        # Create all sql engines in the binds dictionary
        # Quietly fails if the engine is not recognised,
        # it my be a NoSQL store
        for name, bind in tuple(binds.items()):
            key = None if name == 'default' else name
            try:
                self._engines[key] = create_engine(bind)
            except exc.NoSuchModuleError:
                self._nosql_engines[key] = create_store(bind)
        #
        if self._nosql_engines and not self.app.green_pool:
            raise ImproperlyConfigured('NoSql stores requires GREEN_POOL')

        for label, mod in module_iterator(self.app.config['EXTENSIONS']):
            # Loop through attributes in mod_models
            for name in dir(mod):
                value = getattr(mod, name)
                if isinstance(value, (Table, DeclarativeMeta)):
                    for table in value.metadata.sorted_tables:
                        if table.key not in self.metadata.tables:
                            engine = None
                            label = table.info.get('bind_label')
                            keys = ('%s.%s' % (label, table.key),
                                    label, None) if label else (None,)
                            for key in keys:
                                engine = self.get_engine(key)
                                if engine:
                                    break
                            assert engine
                            table.tometadata(self.metadata)
                            self.binds[table] = engine
                    if (isinstance(value, DeclarativeMeta) and
                            hasattr(value, '__table__')):
                        table = value.__table__
                        self._declarative_register[table.key] = value
开发者ID:tazo90,项目名称:lux,代码行数:49,代码来源:mapper.py


示例17: setup

    def setup(self, environ):
        '''Called once only to setup the WSGI application handler.

        Check :ref:`lazy wsgi handler <wsgi-lazy-handler>`
        section for further information.
        '''
        cfg = environ['pulsar.cfg']
        loop = environ['pulsar.connection']._loop
        self.store = create_store(cfg.data_store, loop=loop)
        pubsub = self.store.pubsub(protocol=Protocol())
        channel = '%s_webchat' % self.name
        pubsub.subscribe(channel)
        return WsgiHandler([Router('/', get=self.home_page),
                            WebSocket('/message', Chat(pubsub, channel)),
                            Router('/rpc', post=Rpc(pubsub, channel))])
开发者ID:LoganTK,项目名称:pulsar,代码行数:15,代码来源:manage.py


示例18: setup

    def setup(self, environ):
        '''Called once only to setup the WSGI application handler.

        Check :ref:`lazy wsgi handler <wsgi-lazy-handler>`
        section for further information.
        '''
        cfg = environ['pulsar.cfg']
        loop = environ['pulsar.connection']._loop
        self.store = data.create_store(cfg.data_store, loop=loop)
        pubsub = self.store.pubsub(protocol=WsProtocol())
        channel = '%s_messages' % self.name
        pubsub.subscribe(channel)
        middleware = [wsgi.Router('/', get=self.home_page),
                      ws.WebSocket('/message', PhilosopherWs(pubsub, channel)),
                      wsgi.FileRouter('/favicon.ico', FAVICON),
                      wsgi.MediaRouter('media', ASSET_DIR)]
        return wsgi.WsgiHandler(middleware)
开发者ID:axisofentropy,项目名称:pulsar,代码行数:17,代码来源:manage.py


示例19: check_server

def check_server(name):
    '''Check if server ``name`` is available at the address specified
    ``<name>_server`` config value.

    :rtype: boolean
    '''
    cfg = get_actor().cfg
    cfgname = '%s_server' % name
    addr = cfg.get('%s_server' % name)
    if ('%s://' % name) not in addr:
        addr = '%s://%s' % (name, addr)
    sync_store = create_store(addr, loop=new_event_loop())
    try:
        sync_store.ping()
        return True
    except Exception:
        return False
开发者ID:huobao36,项目名称:pulsar,代码行数:17,代码来源:utils.py


示例20: setup

    def setup(self, environ):
        '''Called once only by the WSGI server.

        It returns a :class:`.WsgiHandler` with three routes:

        * The base route served by the :meth:`home_page` method
        * The websocket route
        * A route for static files
        '''
        cfg = environ['pulsar.cfg']
        # Create the store and the pubsub handler
        self.store = create_store(cfg.data_store)
        pubsub = self.store.pubsub()
        # subscribe to channel
        ensure_future(self.subscribe(pubsub))
        return WsgiHandler([Router('/', get=self.home_page),
                            MediaRouter('/static', STATIC_DIR),
                            WebSocket('/message',
                                      TweetsWsHandler(pubsub, self.channel))])
开发者ID:juanignaciocatalano,项目名称:pulsar,代码行数:19,代码来源:web.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python http.HttpClient类代码示例发布时间:2022-05-25
下一篇:
Python addon.ADDON类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap