本文整理汇总了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()
示例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()
示例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")
示例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))
示例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()
示例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()
示例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")