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


Python uwsgi.worker_id函数代码示例

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


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

示例1: fork_happened2

def fork_happened2():
    if uwsgi.i_am_the_spooler():
        return
    print("worker %d is waiting for signal 100..." % uwsgi.worker_id())
    uwsgi.signal_wait(100)
    print("worker %d received signal %d" % (uwsgi.worker_id(), uwsgi.signal_received()))
    print("fork() has been called [2] wid: %d" % uwsgi.worker_id())
开发者ID:Perkville,项目名称:uwsgi,代码行数:7,代码来源:decoratortest.py

示例2: a_post_fork_thread

def a_post_fork_thread():
    while True:
        time.sleep(3)
        if uwsgi.i_am_the_spooler():
            print("Hello from a thread in the spooler")
        else:
            print("Hello from a thread in worker %d" % uwsgi.worker_id())
开发者ID:Perkville,项目名称:uwsgi,代码行数:7,代码来源:decoratortest.py

示例3: __init__

 def __init__(self):
     self.last_msg = None
     self.arena = "arena{}".format(uwsgi.worker_id())
     self.redis = redis.StrictRedis()
     self.channel = self.redis.pubsub()
     self.channel.subscribe(self.arena)
     self.redis_fd = self.channel.connection._sock.fileno()
开发者ID:20tab,项目名称:robotab,代码行数:7,代码来源:robotab_bullet.py

示例4: index

def index():
    import uwsgi
    message = 'This is a notification from worker %d' % uwsgi.worker_id()
    db.session.execute(fawn.notify('ws', message))
    db.session.commit()

    return """
    <script>
        var s = new WebSocket("ws://" + location.host + "/ws/" + (Math.random() * 1000 << 1));
        s.onopen = e => document.body.innerHTML += 'Socket opened' + '<br>'
        s.onmessage = e => document.body.innerHTML += e.data + '<br>'
        s.onerror = e => document.body.innerHTML += 'Error <br>'
        s.onclose = e => document.body.innerHTML += 'connection closed' + '<br>'
    </script>
    Page rendered on worker %d <br>
    """ % uwsgi.worker_id()
开发者ID:paradoxxxzero,项目名称:fawn,代码行数:16,代码来源:little_flask_example.py

示例5: 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

示例6: application

def application(env, start_response):

    start_response('200 Ok', [('Content-Type', 'text/html')])

    yield "I am the worker %d<br/>" % uwsgi.worker_id()

    grunt = uwsgi.grunt()

    if grunt is None:
        print "worker %d detached" % uwsgi.worker_id()
    else:
        yield "And now i am the grunt with a fix worker id of %d<br/>" % uwsgi.worker_id()
        time.sleep(2)
        yield "Now, i will start a very slow task...<br/>"
        for i in xrange(1, 10):
            yield "waiting for %d seconds<br/>" % i
            time.sleep(i)
开发者ID:Algy,项目名称:uwsgi,代码行数:17,代码来源:grunter.py

示例7: spawn_consumers

def spawn_consumers():
    global q
    q = Queue.Queue()
    for i in range(CONSUMERS):
        t = Thread(target=consumer,args=(q,))
        t.daemon = True
        t.start()
        print("consumer %d on worker %d started" % (i, uwsgi.worker_id()))
开发者ID:20tab,项目名称:uwsgi,代码行数:8,代码来源:taskqueue.py

示例8: application

def application(environ, start_response):

    gevent.sleep()
    start_response('200 OK', [('Content-Type', 'text/html')])
    yield "sleeping for 3 seconds...<br/>"
    gevent.sleep(3)
    yield "done<br/>"
    gevent.spawn(microtask, uwsgi.worker_id())
    yield "microtask started<br/>"
开发者ID:Algy,项目名称:uwsgi,代码行数:9,代码来源:testgevent.py

示例9: __init__

    def __init__(self):
        ServiceBase.__init__(self)
        ProfileMixin.__init__(self)
        DispatcherMixin_CRR.__init__(self)

        if not uwsgi.cache_exists('Service2Counter'):
            uwsgi.cache_set('Service2Counter', '0')
        if not uwsgi.cache_exists('Service2Timer'):
            uwsgi.cache_set('Service2Timer', '0')
        print uwsgi.queue_size
        gevent.spawn(microtask, uwsgi.worker_id())
        print 'after gevent.spawn'
开发者ID:kasworld,项目名称:tiny_uwsgi,代码行数:12,代码来源:service2.py

示例10: spawn_on_socket

def spawn_on_socket(fd):
    worker_id = uwsgi.worker_id()
    application = make_app(debug=options.debug)
    server = HTTPServer(application, xheaders=True, max_body_size=options.max_body_size)
    sock = socket.fromfd(fd, socket.AF_INET, socket.SOCK_STREAM)
    server.add_sockets([sock])

    if options.prometheus_port:
        prometheus_port = options.prometheus_port + worker_id
        uwsgi.log('starting prometheus server on port %d' % prometheus_port)
        start_http_server(prometheus_port)
    uwsgi.log('tornado plumber reporting for duty on uWSGI worker %s' % worker_id)
开发者ID:Qabel,项目名称:qabel-block,代码行数:12,代码来源:uwsgi_plumbing.py

示例11: 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

示例12: set_uwsgi_proc_name

def set_uwsgi_proc_name():
    build_dir = os.path.basename(project_root)
    try:
        deploy_tag = open(os.path.join(project_root, '.DEPLOY_TAG')).read().strip()
    except IOError:
        deploy_tag = '?'

    os.environ['DEPLOY_TAG'] = deploy_tag

    uwsgi.setprocname("uwsgi worker %(worker_id)d <%(build)s> [%(tag)s]" % {
        'worker_id': uwsgi.worker_id(),
        'build': build_dir,
        'tag': deploy_tag,
    })
开发者ID:hadjango,项目名称:djangocon-2016-demo,代码行数:14,代码来源:wsgi.py

示例13: application

def application(environ, start_response):
    global _application

    uwsgi.set_logvar('worker_id', str(uwsgi.worker_id()))

    if not os.environ.get('DJANGO_SETTINGS_MODULE'):
        os.environ['DJANGO_SETTINGS_MODULE'] = environ.get('DJANGO_SETTINGS_MODULE', 'settings')

    if _application is None:
        try:
            from django.core.wsgi import get_wsgi_application
        except ImportError:
            import django.core.handlers.wsgi
            _application = django.core.handlers.wsgi.WSGIHandler()
        else:
            _application = get_wsgi_application()

    return _application(environ, start_response)
开发者ID:hadjango,项目名称:djangocon-2016-demo,代码行数:18,代码来源:wsgi.py

示例14: index

def index():
    return """
    <script>
        var sockets = [];
        function handle_socket(i) {
            var s = new WebSocket("ws://" + location.host + "/ws/" + i);
            s.onopen = e => document.body.innerHTML += i + ' opened  <br>'
            s.onmessage = e => document.body.innerHTML += e.data + ' (' + i + ') <br>'
            s.onerror = e => document.body.innerHTML += 'Error (' + i + ')<br>'
            s.onclose = e => document.body.innerHTML += 'Socket closed (' + i + ')<br>'
            return s;
        }
        document.addEventListener('DOMContentLoaded', function () {
            for (var i = 0; i < 10; i++) {
                sockets.push(handle_socket(i))
            }
        });
    </script>
    Page rendered on worker %d <br>
    """ % uwsgi.worker_id()
开发者ID:paradoxxxzero,项目名称:fawn,代码行数:20,代码来源:several_sockets_flask_example.py

示例15: __init__

    def __init__(self, game, name, avatar, fd, x, y, r, color, speed=15):
        self.game = game
        self.name = name
        self.avatar = avatar
        self.fd = fd

        self.arena_object = ArenaObject(x, y, r, speed)

        self.attack = 0
        self.energy = 100.0

        self.arena = "arena{}".format(uwsgi.worker_id())
        self.redis = redis.StrictRedis()
        self.channel = self.redis.pubsub()
        self.channel.subscribe(self.arena)
        self.redis_fd = self.channel.connection._sock.fileno()

        self.cmd = None
        self.attack_cmd = None
        self.bullet = Bullet(self.game, self)
        self.color = color
开发者ID:20tab,项目名称:robotab,代码行数:21,代码来源:robotab_orig.py


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