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


Python uwsgi.mule_id函数代码示例

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


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

示例1: __call__

 def __call__(self):
     if uwsgi.mule_id() == self.num:
         print " i am the mule"
         while True:
             message = uwsgi.mule_get_msg()
             if message:
                 self.f(message)
开发者ID:sashka,项目名称:uwsgi,代码行数:7,代码来源:uwsgidecorators.py

示例2: main

def main():
    # connect and declare the message queue/kombu objects.
    # only py-amqp supports ssl and doesn't recognize amqps
    # so fix up the connection string accordingly
    connString = 'amqp://{0}:{1}@{2}:{3}/{4}'.format(options.mquser, options.mqpassword, options.mqserver, options.mqport, options.mqvhost)
    if options.mqprotocol == 'amqps':
        mqSSL = True
    else:
        mqSSL = False
    mqConn = Connection(connString, ssl=mqSSL)
    # Task Exchange for events sent via http for us to normalize and post to elastic search
    if options.mqack:
        # conservative, store msgs to disk, ack each message
        eventTaskExchange = Exchange(name=options.taskexchange, type='direct', durable=True, delivery_mode=2)
    else:
        # fast, transient delivery, store in memory only, auto-ack messages
        eventTaskExchange = Exchange(name=options.taskexchange, type='direct', durable=True, delivery_mode=1)
    eventTaskExchange(mqConn).declare()
    # Queue for the exchange
    if options.mqack:
        eventTaskQueue = Queue(options.taskexchange, exchange=eventTaskExchange, routing_key=options.taskexchange, durable=True, no_ack=False)
    else:
        eventTaskQueue = Queue(options.taskexchange, exchange=eventTaskExchange, routing_key=options.taskexchange, durable=True, no_ack=True)
    eventTaskQueue(mqConn).declare()

    # topic exchange for anyone who wants to queue and listen for mozdef.event
    eventTopicExchange = Exchange(name=options.eventexchange, type='topic', durable=False, delivery_mode=1)
    eventTopicExchange(mqConn).declare()

    if hasUWSGI:
        logger.info("started as uwsgi mule {0}".format(uwsgi.mule_id()))
    else:
        logger.info('started without uwsgi')
    # consume our queue and publish on the topic exchange
    taskConsumer(mqConn, eventTaskQueue, eventTopicExchange, es).run()
开发者ID:IFGHou,项目名称:MozDef,代码行数:35,代码来源:esworker_eventtask.py

示例3: _mule_index_in_farm

 def _mule_index_in_farm(self, farm_name, mule_id=None):
     mule_id = mule_id or uwsgi.mule_id()
     try:
         mules = self.configured_pools[farm_name]
         return mules.index(mule_id)
     except (KeyError, ValueError):
         return -1
开发者ID:msauria,项目名称:galaxy,代码行数:7,代码来源:__init__.py

示例4: __call__

 def __call__(self):
     if uwsgi.mule_id() == self.num:
         try:
             self.f()
         except:
             exc = sys.exc_info()
             sys.excepthook(exc[0], exc[1], exc[2])
             sys.exit(1)
开发者ID:NewAmericanPublicArt,项目名称:color-commons,代码行数:8,代码来源:uwsgidecorators.py

示例5: register_postfork_function

 def register_postfork_function(cls, f, *args, **kwargs):
     if uwsgi.mule_id() == 0:
         cls.postfork_functions.append((f, args, kwargs))
     else:
         # mules are forked from the master and run the master's postfork functions immediately before the forked
         # process is replaced. that is prevented in the _do_uwsgi_postfork function, and because programmed mules
         # are standalone non-forking processes, they should run postfork functions immediately
         f(*args, **kwargs)
开发者ID:ImmPortDB,项目名称:immport-galaxy,代码行数:8,代码来源:__init__.py

示例6: instance_id

 def instance_id(self):
     if not self._is_mule:
         instance_id = uwsgi.worker_id()
     elif self._farm_name:
         return self._mule_index_in_farm(self._farm_name) + 1
     else:
         instance_id = uwsgi.mule_id()
     return instance_id
开发者ID:ImmPortDB,项目名称:immport-galaxy,代码行数:8,代码来源:__init__.py

示例7: _do_uwsgi_postfork

def _do_uwsgi_postfork():
    for i, mule in enumerate(_uwsgi_configured_mules()):
        if mule is not True and i + 1 == uwsgi.mule_id():
            # mules will inherit the postfork function list and call them immediately upon fork, but programmed mules
            # should not do that (they will call the postfork functions in-place as they start up after exec())
            UWSGIApplicationStack.postfork_functions = [(_mule_fixup, (), {})]
    for f, args, kwargs in [t for t in UWSGIApplicationStack.postfork_functions]:
        log.debug('Calling postfork function: %s', f)
        f(*args, **kwargs)
开发者ID:ImmPortDB,项目名称:immport-galaxy,代码行数:9,代码来源:__init__.py

示例8: __call__

 def __call__(self):
     if uwsgi.mule_id() == self.num:
         while True:
             try:
                 self.f()
             except BaseException:
                 exc = sys.exc_info()
                 sys.excepthook(exc[0], exc[1], exc[2])
                 sys.exit(1)
开发者ID:EasyPost,项目名称:uwsgi,代码行数:9,代码来源:uwsgidecorators.py

示例9: __init__

 def __init__(self, mqConnection, taskQueue, topicExchange, esConnection):
     self.connection = mqConnection
     self.esConnection = esConnection
     self.taskQueue = taskQueue
     self.topicExchange = topicExchange
     self.mqproducer = self.connection.Producer(serializer='json')
     if hasUWSGI:
         self.muleid = uwsgi.mule_id()
     else:
         self.muleid = 0
开发者ID:IFGHou,项目名称:MozDef,代码行数:10,代码来源:esworker_eventtask.py

示例10: main

def main():
    if hasUWSGI:
        logger.info("started as uwsgi mule {0}".format(uwsgi.mule_id()))
    else:
        logger.info('started without uwsgi')

    # establish api interface with papertrail
    ptRequestor = PTRequestor(options.ptapikey, evmax=options.ptquerymax)

    # consume our queue
    taskConsumer(ptRequestor, es).run()
开发者ID:Phrozyn,项目名称:MozDef,代码行数:11,代码来源:esworker_papertrail.py

示例11: __init__

 def __init__(self, mqConnection, taskQueue,  esConnection):
     self.connection = mqConnection
     self.esConnection = esConnection
     self.taskQueue = taskQueue
     self.mqproducer = self.connection.Producer(serializer='json')
     if hasUWSGI:
         self.muleid = uwsgi.mule_id()
     else:
         self.muleid = 0
     if options.esbulksize != 0:
         # if we are bulk posting enable a timer to occasionally flush the pyes bulker even if it's not full
         # to prevent events from sticking around an idle worker
         Timer(options.esbulktimeout, self.flush_es_bulk).start()
开发者ID:526avijitgupta,项目名称:MozDef,代码行数:13,代码来源:esworker.py

示例12: facts

 def facts(self):
     facts = super(UWSGIApplicationStack, self).facts
     if not self._is_mule:
         facts.update({
             'pool_name': 'web',
             'server_id': uwsgi.worker_id(),
         })
     else:
         facts.update({
             'pool_name': self._farm_name,
             'server_id': uwsgi.mule_id(),
         })
     facts['instance_id'] = self.instance_id
     return facts
开发者ID:ImmPortDB,项目名称:immport-galaxy,代码行数:14,代码来源:__init__.py

示例13: main

def main():
    # connect and declare the message queue/kombu objects.

    # what sort of message queue are we talking to?
    if options.mqprotocol in ('amqp', 'amqps'):

        # only py-amqp supports ssl and doesn't recognize amqps
        # so fix up the connection string accordingly
        connString = 'amqp://{0}:{1}@{2}:{3}/{4}'.format(options.mquser, options.mqpassword, options.mqserver, options.mqport, options.mqvhost)
        if options.mqprotocol == 'amqps':
            mqSSL = True
        else:
            mqSSL = False
        mqConn = Connection(connString, ssl=mqSSL)
        # Task Exchange for events sent via http for us to normalize and post to elastic search
        if options.mqack:
            # conservative, store msgs to disk, ack each message
            eventTaskExchange = Exchange(name=options.taskexchange, type='direct', durable=True, delivery_mode=2)
        else:
            # fast, transient delivery, store in memory only, auto-ack messages
            eventTaskExchange = Exchange(name=options.taskexchange, type='direct', durable=True, delivery_mode=1)
        eventTaskExchange(mqConn).declare()
        # Queue for the exchange
        if options.mqack:
            eventTaskQueue = Queue(options.taskexchange, exchange=eventTaskExchange, routing_key=options.taskexchange, durable=True, no_ack=False)
        else:
            eventTaskQueue = Queue(options.taskexchange, exchange=eventTaskExchange, routing_key=options.taskexchange, durable=True, no_ack=True)
        eventTaskQueue(mqConn).declare()

        # topic exchange for anyone who wants to queue and listen for mozdef.event
        # commented out to begin deprecation for this feature
        # eventTopicExchange = Exchange(name=options.eventexchange, type='topic', durable=False, delivery_mode=1)
        # eventTopicExchange(mqConn).declare()

    if options.mqprotocol in ('sqs'):
        # amazon SQS
        connString = 'sqs://%s:%[email protected]' % (urllib.quote(options.accesskey, safe=''), urllib.quote(options.secretkey, safe=''))

        mqConn = Connection(connString, transport_options=dict(region=options.region))
        # for sqs, set taskexchange to the sqs queue name.
        eventTaskQueue = mqConn.SimpleQueue(options.taskexchange)


    if hasUWSGI:
        sys.stdout.write("started as uwsgi mule {0}\n".format(uwsgi.mule_id()))
    else:
        sys.stdout.write('started without uwsgi\n')
    # consume our queue
    taskConsumer(mqConn, eventTaskQueue, es).run()
开发者ID:526avijitgupta,项目名称:MozDef,代码行数:49,代码来源:esworker.py

示例14: start

    def start(self):
        """ Post-fork initialization.

        This is mainly done here for the future possibility that we'll be able to run mules post-fork without exec()ing. In a programmed mule it could be done at __init__ time.
        """
        if self.stack._is_mule:
            if not uwsgi.in_farm():
                raise RuntimeError('Mule %s is not in a farm! Set `farm = <pool_name>:%s` in uWSGI configuration'
                                   % (uwsgi.mule_id(),
                                      ','.join(map(str, range(1, len([x for x in self.stack._configured_mules if x.endswith('galaxy/main.py')]) + 1)))))
            elif len(self.stack._farms) > 1:
                raise RuntimeError('Mule %s is in multiple farms! This configuration is not supported due to locking issues' % uwsgi.mule_id())
            # only mules receive messages so don't bother starting the dispatcher if we're not a mule (although
            # currently it doesn't have any registered handlers and so wouldn't start anyway)
            super(UWSGIFarmMessageTransport, self).start()
开发者ID:msauria,项目名称:galaxy,代码行数:15,代码来源:transport.py

示例15: main

def main():
    if hasUWSGI:
        logger.info("started as uwsgi mule {0}".format(uwsgi.mule_id()))
    else:
        logger.info('started without uwsgi')

    if options.mqprotocol not in ('sqs'):
        logger.error('Can only process SQS queues, terminating')
        sys.exit(1)

    sqs_conn, eventTaskQueue = connect_sqs(
        task_exchange=options.taskexchange,
        **get_aws_credentials(
            options.region,
            options.accesskey,
            options.secretkey))
    # consume our queue
    taskConsumer(sqs_conn, eventTaskQueue, es, options).run()
开发者ID:Phrozyn,项目名称:MozDef,代码行数:18,代码来源:esworker_sns_sqs.py


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