本文整理汇总了Python中autobahn.twisted.websocket.WampWebSocketServerProtocol.connectionLost方法的典型用法代码示例。如果您正苦于以下问题:Python WampWebSocketServerProtocol.connectionLost方法的具体用法?Python WampWebSocketServerProtocol.connectionLost怎么用?Python WampWebSocketServerProtocol.connectionLost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autobahn.twisted.websocket.WampWebSocketServerProtocol
的用法示例。
在下文中一共展示了WampWebSocketServerProtocol.connectionLost方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: connectionLost
# 需要导入模块: from autobahn.twisted.websocket import WampWebSocketServerProtocol [as 别名]
# 或者: from autobahn.twisted.websocket.WampWebSocketServerProtocol import connectionLost [as 别名]
def connectionLost(self, reason):
try:
log.msg("Connection to node controller lost.")
WampWebSocketServerProtocol.connectionLost(self, reason)
except:
pass
finally:
## loosing the connection to the node controller (the pipes) is fatal.
## stop the reactor and exit with error
if reactor.running:
reactor.addSystemEventTrigger('after', 'shutdown', os._exit, 1)
reactor.stop()
else:
sys.exit(1)
示例2: connectionLost
# 需要导入模块: from autobahn.twisted.websocket import WampWebSocketServerProtocol [as 别名]
# 或者: from autobahn.twisted.websocket.WampWebSocketServerProtocol import connectionLost [as 别名]
def connectionLost(self, reason):
try:
# this log message is unlikely to reach the controller (unless
# only stdin/stdout pipes were lost, but not stderr)
log.msg("Connection to node controller lost.")
WampWebSocketServerProtocol.connectionLost(self, reason)
except:
pass
finally:
# loosing the connection to the node controller is fatal:
# stop the reactor and exit with error
if reactor.running:
reactor.addSystemEventTrigger('after', 'shutdown', os._exit, 1)
reactor.stop()
示例3: connectionLost
# 需要导入模块: from autobahn.twisted.websocket import WampWebSocketServerProtocol [as 别名]
# 或者: from autobahn.twisted.websocket.WampWebSocketServerProtocol import connectionLost [as 别名]
def connectionLost(self, reason):
# the behavior here differs slightly whether we're shutting down orderly
# or shutting down because of "issues"
if isinstance(reason.value, ConnectionDone):
was_clean = True
else:
was_clean = False
try:
# this log message is unlikely to reach the controller (unless
# only stdin/stdout pipes were lost, but not stderr)
if was_clean:
log.info("Connection to node controller closed cleanly")
else:
log.warn("Connection to node controller lost: {reason}", reason=reason)
# give the WAMP transport a change to do it's thing
WampWebSocketServerProtocol.connectionLost(self, reason)
except:
# we're in the process of shutting down .. so ignore ..
pass
finally:
# after the connection to the node controller is gone,
# the worker is "orphane", and should exit
# determine process exit code
if was_clean:
exit_code = 0
else:
exit_code = 1
# exit the whole worker process when the reactor has stopped
reactor.addSystemEventTrigger('after', 'shutdown', os._exit, exit_code)
# stop the reactor
try:
reactor.stop()
except ReactorNotRunning:
pass
示例4: connectionLost
# 需要导入模块: from autobahn.twisted.websocket import WampWebSocketServerProtocol [as 别名]
# 或者: from autobahn.twisted.websocket.WampWebSocketServerProtocol import connectionLost [as 别名]
def connectionLost(self, reason):
WampWebSocketServerProtocol.connectionLost(self, reason)
self.factory.connectionLost(reason)