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

Python uwsgi.worker_id函数代码示例

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

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



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


示例16: init

def init():
    schema = Schema(title=TEXT(stored=True),
                    path=TEXT(stored=True),
                    content=TEXT)

    rel = dirname(__file__)
    index_name = 'index'
    if no_uwsgi:
        # attenzione: il restart provochera' la creazione di nuove cartelle
        # ogni volta...
        index_name += '{0}'.format(os.getpid())
    else:
        index_name += '{0}'.format(uwsgi.worker_id())

    index_dir = join(rel, index_name)

    if not exists(index_dir):
        mkdir(index_dir)

    logging.debug('create lyrics index')

    global ix
    ix = create_in(index_dir, schema)

    writer = ix.writer()

    lyrics_dir = join(rel, 'items')

    onlyfiles = [f for f in listdir(lyrics_dir) if isfile(join(lyrics_dir, f))]
    for file in onlyfiles:
        with open(join(lyrics_dir, file), encoding="utf-8") as f:
            cnt = f.read()
            link = cnt.splitlines()[0]

            writer.add_document(
                    title=file,
                    content=cnt,
                    path=link)

    writer.commit()
开发者ID:Shevraar,项目名称:jovabot,代码行数:40,代码来源:__init__.py


示例17: __init__

    def __init__(self, game, name, avatar, fd, x, y, z, r, color, scale=5, speed=15):
        self.size_x = 30 
        self.size_y = 35
        self.size_z = 45 
        super(Player, self).__init__(game, 90.0, self.size_x, self.size_y, self.size_z, x, y, z, r)
        self.name = name
        self.avatar = avatar
        self.fd = fd

        self.last_msg = None

        self.scale = scale

        # 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.bullet = Bullet(self.game, self)
        self.color = color
开发者ID:Jiloc,项目名称:robotab,代码行数:24,代码来源:robotab_bullet.py


示例18: __call__

 def __call__(self, *args, **kwargs):
     if self.f:
         if self.wid > 0 and self.wid != uwsgi.worker_id():
             return
         return self.f()
     self.f = args[0]
开发者ID:NewAmericanPublicArt,项目名称:color-commons,代码行数:6,代码来源:uwsgidecorators.py


示例19: application

def application(env, start_response):
    try:
        uwsgi.mule_msg(env['REQUEST_URI'], 1)
    except:
        pass

    req = uwsgi.workers()[uwsgi.worker_id()-1]['requests']

    uwsgi.setprocname("worker %d managed %d requests" % (uwsgi.worker_id(), req))

    try:
        gc.collect(2)
    except:
        pass
    if DEBUG:
        print(env['wsgi.input'].fileno())

    if env['PATH_INFO'] in routes:
        return routes[env['PATH_INFO']](env, start_response)


    if DEBUG:
        print(env['wsgi.input'].fileno())

    try:
        gc.collect(2)
    except:
        pass

    if DEBUG:
        print(len(gc.get_objects()))

    workers = ''
    for w in uwsgi.workers():
        apps = '<table border="1"><tr><th>id</th><th>mountpoint</th><th>startup time</th><th>requests</th></tr>'
        for app in w['apps']:
            apps += '<tr><td>%d</td><td>%s</td><td>%d</td><td>%d</td></tr>' % (app['id'], app['mountpoint'], app['startup_time'], app['requests']) 
        apps += '</table>'
        workers += """
<tr>
<td>%d</td><td>%d</td><td>%s</td><td>%d</td><td>%d</td><td>%d</td><td>%s</td>
</tr>
        """ % (w['id'], w['pid'], w['status'], w['running_time']/1000, w['avg_rt']/1000, w['tx'], apps)

    output = """
<img src="/logo"/> version %s running on %s (remote user: %s)<br/>
<hr size="1"/>

Configuration<br/>
<iframe src="/config"></iframe><br/>

<br/>

Dynamic options<br/>
<iframe src="/options"></iframe><br/>

<br/>
Workers and applications<br/>
<table border="1">
<tr>
<th>wid</th><th>pid</th><th>status</th><th>running time</th><th>average</th><th>tx</th><th>apps</th>
</tr>
%s
</table>

    """ % (uwsgi.version, uwsgi.hostname, env.get('REMOTE_USER','None'), workers)

    start_response('200 OK', [('Content-Type', 'text/html'), ('Content-Length', str(len(output)) )])

    #return bytes(output.encode('latin1'))
    return output
开发者ID:StephenPierce,项目名称:uwsgi,代码行数:71,代码来源:welcome.py


示例20: setprocname

def setprocname():
    if uwsgi.worker_id() > 0:
        uwsgi.setprocname("i am the worker %d" % uwsgi.worker_id())
开发者ID:StephenPierce,项目名称:uwsgi,代码行数:3,代码来源:welcome.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.check_body函数代码示例发布时间:2022-05-26
下一篇:
Python uwsgi.websocket_send函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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