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


Python NativeProcessSession.onJoin方法代码示例

本文整理汇总了Python中crossbar.common.process.NativeProcessSession.onJoin方法的典型用法代码示例。如果您正苦于以下问题:Python NativeProcessSession.onJoin方法的具体用法?Python NativeProcessSession.onJoin怎么用?Python NativeProcessSession.onJoin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在crossbar.common.process.NativeProcessSession的用法示例。


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

示例1: onJoin

# 需要导入模块: from crossbar.common.process import NativeProcessSession [as 别名]
# 或者: from crossbar.common.process.NativeProcessSession import onJoin [as 别名]
    def onJoin(self, details, publish_ready=True):
        """
        Called when worker process has joined the node's management realm.
        """
        yield NativeProcessSession.onJoin(self, details)

        procs = [
            # CPU affinity for this worker process
            'get_cpu_affinity',
            'set_cpu_affinity',

            # PYTHONPATH used for this worker
            'get_pythonpath',
            'add_pythonpath',

            # profiling control
            'get_profilers',
            'start_profiler',
            'query_profile',
        ]

        dl = []
        for proc in procs:
            uri = '{}.{}'.format(self._uri_prefix, proc)
            self.log.debug("Registering management API procedure {proc}", proc=uri)
            dl.append(self.register(getattr(self, proc), uri, options=RegisterOptions(details_arg='details')))

        regs = yield DeferredList(dl)

        self.log.debug("Registered {cnt} management API procedures", cnt=len(regs))

        if publish_ready:
            yield self.publish_ready()
开发者ID:Tsunami2069,项目名称:crossbar,代码行数:35,代码来源:worker.py

示例2: onJoin

# 需要导入模块: from crossbar.common.process import NativeProcessSession [as 别名]
# 或者: from crossbar.common.process.NativeProcessSession import onJoin [as 别名]
   def onJoin(self, details, publish_ready = True):
      """
      Called when worker process has joined the node's management realm.
      """
      yield NativeProcessSession.onJoin(self, details)

      procs = [
         'get_cpu_affinity',
         'set_cpu_affinity',
         'get_pythonpath',
         'add_pythonpath',
      ]

      dl = []
      for proc in procs:
         uri = '{}.{}'.format(self._uri_prefix, proc)
         if self.debug:
            log.msg("Registering procedure '{}'".format(uri))
         dl.append(self.register(getattr(self, proc), uri, options = RegisterOptions(details_arg = 'details', discloseCaller = True)))

      regs = yield DeferredList(dl)

      if self.debug:
         log.msg("{} registered {} procedures".format(self.__class__.__name__, len(regs)))

      if publish_ready:
         yield self.publish_ready()
开发者ID:Inspire2Innovate,项目名称:crossbar,代码行数:29,代码来源:native.py

示例3: onJoin

# 需要导入模块: from crossbar.common.process import NativeProcessSession [as 别名]
# 或者: from crossbar.common.process.NativeProcessSession import onJoin [as 别名]
    def onJoin(self, details):

        self.log.info("Joined realm '{realm}' on node management router", realm=details.realm)

        # When a (native) worker process has connected back to the router of
        # the node controller, the worker will publish this event
        # to signal it's readyness.
        #
        def on_worker_ready(res):
            id = res['id']
            if id in self._workers:
                ready = self._workers[id].ready
                if not ready.called:
                    # fire the Deferred previously stored for
                    # signaling "worker ready"
                    ready.callback(id)
                else:
                    self.log.error("Internal error: on_worker_ready() fired for process {process}, but already called earlier",
                                   process=id)
            else:
                self.log.error("Internal error: on_worker_ready() fired for process {process}, but no process with that ID",
                               process=id)

        self.subscribe(on_worker_ready, 'crossbar.node.{}.on_worker_ready'.format(self._node_id))

        yield NativeProcessSession.onJoin(self, details)

        # register node controller procedures: 'crossbar.node.<ID>.<PROCEDURE>'
        #
        procs = [
            'shutdown',
            'get_info',
            'get_workers',
            'get_worker_log',
            'start_router',
            'stop_router',
            'start_container',
            'stop_container',
            'start_guest',
            'stop_guest',
            'start_websocket_testee',
            'stop_websocket_testee',
        ]

        dl = []
        for proc in procs:
            uri = '{}.{}'.format(self._uri_prefix, proc)
            self.log.debug("Registering management API procedure {proc}", proc=uri)
            dl.append(self.register(getattr(self, proc), uri, options=RegisterOptions(details_arg='details')))

        regs = yield DeferredList(dl)

        self.log.debug("Registered {cnt} management API procedures", cnt=len(regs))

        self._started = utcnow()

        self.publish(u"crossbar.node.on_ready", self._node_id)

        self.log.debug("Node controller ready")
开发者ID:v09-software,项目名称:crossbar,代码行数:61,代码来源:process.py

示例4: onJoin

# 需要导入模块: from crossbar.common.process import NativeProcessSession [as 别名]
# 或者: from crossbar.common.process.NativeProcessSession import onJoin [as 别名]
    def onJoin(self, details):

        # When a (native) worker process has connected back to the router of
        # the node controller, the worker will publish this event
        # to signal it's readyness.
        #
        def on_worker_ready(res):
            id = res['id']
            if id in self._workers:
                ready = self._workers[id].ready
                if not ready.called:
                    # fire the Deferred previously stored for
                    # signaling "worker ready"
                    ready.callback(id)
                else:
                    self.log.error("INTERNAL ERROR: on_worker_ready() fired for process {process} - ready already called",
                                   process=id)
            else:
                self.log.error("INTERNAL ERROR: on_worker_ready() fired for process {process} - no process with that ID",
                               process=id)

        self.subscribe(on_worker_ready, 'crossbar.node.{}.on_worker_ready'.format(self._node_id))

        yield NativeProcessSession.onJoin(self, details)

        # register node controller procedures: 'crossbar.node.<ID>.<PROCEDURE>'
        #
        procs = [
            'shutdown',
            'start_management_transport',
            'get_info',
            'get_workers',
            'get_worker_log',
            'start_router',
            'stop_router',
            'start_container',
            'stop_container',
            'start_guest',
            'stop_guest',
        ]

        dl = []
        for proc in procs:
            uri = '{}.{}'.format(self._uri_prefix, proc)
            self.log.debug("Registering procedure '{uri}'", uri=uri)
            dl.append(self.register(getattr(self, proc), uri, options=RegisterOptions(details_arg='details')))

        regs = yield DeferredList(dl)

        self.log.debug("{me} registered {registers} procedures",
                       me=self.__class__.__name__, registers=len(regs))
开发者ID:GoodgameStudios,项目名称:crossbar,代码行数:53,代码来源:process.py

示例5: onJoin

# 需要导入模块: from crossbar.common.process import NativeProcessSession [as 别名]
# 或者: from crossbar.common.process.NativeProcessSession import onJoin [as 别名]
    def onJoin(self, details, publish_ready=True):
        """
        Called when worker process has joined the node's management realm.
        """
        yield NativeProcessSession.onJoin(self, details)
        # above upcall registers all our "@wamp.register(None)" methods

        # setup SIGTERM handler to orderly shutdown the worker
        def shutdown(sig, frame):
            self.log.warn("Native worker received SIGTERM - shutting down ..")
            self.shutdown()
        signal.signal(signal.SIGTERM, shutdown)

        # the worker is ready for work!
        if publish_ready:
            yield self.publish_ready()
开发者ID:dardok,项目名称:crossbar,代码行数:18,代码来源:worker.py

示例6: onJoin

# 需要导入模块: from crossbar.common.process import NativeProcessSession [as 别名]
# 或者: from crossbar.common.process.NativeProcessSession import onJoin [as 别名]
    def onJoin(self, details, publish_ready=True):
        """
        Called when worker process has joined the node's management realm.
        """
        yield NativeProcessSession.onJoin(self, details)

        procs = [
            # orderly shutdown worker "from inside"
            'shutdown',

            # CPU affinity for this worker process
            'get_cpu_count',
            'get_cpu_affinity',
            'set_cpu_affinity',

            # PYTHONPATH used for this worker
            'get_pythonpath',
            'add_pythonpath',

            # profiling control
            'get_profilers',
            'start_profiler',
            'get_profile',
        ]

        dl = []
        for proc in procs:
            uri = '{}.{}'.format(self._uri_prefix, proc)
            self.log.debug("Registering management API procedure {proc}", proc=uri)
            dl.append(self.register(getattr(self, proc), uri, options=RegisterOptions(details_arg='details')))

        regs = yield DeferredList(dl)

        self.log.debug("Registered {cnt} management API procedures", cnt=len(regs))

        # setup SIGTERM handler to orderly shutdown the worker
        def shutdown(sig, frame):
            self.log.warn("Native worker received SIGTERM - shutting down ..")
            self.shutdown()
        signal.signal(signal.SIGTERM, shutdown)

        # the worker is ready for work!
        if publish_ready:
            yield self.publish_ready()
开发者ID:mdabbagh88,项目名称:crossbar,代码行数:46,代码来源:worker.py

示例7: onJoin

# 需要导入模块: from crossbar.common.process import NativeProcessSession [as 别名]
# 或者: from crossbar.common.process.NativeProcessSession import onJoin [as 别名]
    def onJoin(self, details):

        from autobahn.wamp.types import SubscribeOptions

        self.log.debug("Joined realm '{realm}' on node management router", realm=details.realm)

        # When a (native) worker process has connected back to the router of
        # the node controller, the worker will publish this event
        # to signal it's readyness.
        #
        def on_worker_ready(res):
            worker_id = res['id']
            if worker_id in self._workers:
                ready = self._workers[worker_id].ready
                if not ready.called:
                    # fire the Deferred previously stored for
                    # signaling "worker ready"
                    ready.callback(worker_id)
                else:
                    self.log.error("Internal error: on_worker_ready() fired for process {process}, but already called earlier",
                                   process=worker_id)
            else:
                self.log.error("Internal error: on_worker_ready() fired for process {process}, but no process with that ID",
                               process=worker_id)

        self.subscribe(on_worker_ready, u'crossbar.worker..on_worker_ready', SubscribeOptions(match=u'wildcard'))

        yield NativeProcessSession.onJoin(self, details)
        # above upcall registers procedures we have marked with @wamp.register(None)

        # we need to catch SIGINT here to properly shutdown the
        # node explicitly (a Twisted system trigger wouldn't allow us to distinguish
        # different reasons/origins of exiting ..)
        def signal_handler(signal, frame):
            # the following will shutdown the Twisted reactor in the end
            self.shutdown()
        signal.signal(signal.SIGINT, signal_handler)

        self._started = utcnow()

        self.publish(u"crossbar.on_ready")

        self.log.debug("Node controller ready")
开发者ID:NinjaMSP,项目名称:crossbar,代码行数:45,代码来源:process.py


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