本文整理汇总了Python中twisted.protocols.basic.LineReceiver.connectionLost方法的典型用法代码示例。如果您正苦于以下问题:Python LineReceiver.connectionLost方法的具体用法?Python LineReceiver.connectionLost怎么用?Python LineReceiver.connectionLost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.protocols.basic.LineReceiver
的用法示例。
在下文中一共展示了LineReceiver.connectionLost方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: connectionLost
# 需要导入模块: from twisted.protocols.basic import LineReceiver [as 别名]
# 或者: from twisted.protocols.basic.LineReceiver import connectionLost [as 别名]
def connectionLost(self, reason):
"""
Cause any outstanding commands to fail.
"""
self._disconnected = True
self._cancelCommands(reason)
LineReceiver.connectionLost(self, reason)
示例2: connectionLost
# 需要导入模块: from twisted.protocols.basic import LineReceiver [as 别名]
# 或者: from twisted.protocols.basic.LineReceiver import connectionLost [as 别名]
def connectionLost(self, why):
self.connected = 0
self.script_hashes.clear()
self.factory.delConnection(self)
LineReceiver.connectionLost(self, why)
while self.replyQueue.waiting:
self.replyReceived(ConnectionError("Lost connection"))
示例3: connectionLost
# 需要导入模块: from twisted.protocols.basic import LineReceiver [as 别名]
# 或者: from twisted.protocols.basic.LineReceiver import connectionLost [as 别名]
def connectionLost(self, reason):
""" ups... stop reactor """
LineReceiver.connectionLost(self, reason)
print "Connection lost: ", reason.getErrorMessage()
try:
reactor.stop()
except ReactorNotRunning:
print " - reactor not running, so we are not stopping it"
示例4: PostgresMonitor
# 需要导入模块: from twisted.protocols.basic import LineReceiver [as 别名]
# 或者: from twisted.protocols.basic.LineReceiver import connectionLost [as 别名]
class PostgresMonitor(ProcessProtocol):
"""
A monitoring protocol which watches the postgres subprocess.
"""
log = Logger()
def __init__(self, svc=None):
self.lineReceiver = LineReceiver()
self.lineReceiver.delimiter = '\n'
self.lineReceiver.lineReceived = self.lineReceived
self.svc = svc
self.isReady = False
self.completionDeferred = Deferred()
def lineReceived(self, line):
if self.svc is None:
return
if not self.isReady:
if _MAGIC_READY_COOKIE in line:
self.svc.ready()
disconnecting = False
def connectionMade(self):
self.lineReceiver.makeConnection(self)
def outReceived(self, out):
for line in out.split("\n"):
if line:
self.log.info("{message}", message=line)
# self.lineReceiver.dataReceived(out)
def errReceived(self, err):
for line in err.split("\n"):
if line:
self.log.error("{message}", message=line)
self.lineReceiver.dataReceived(err)
def processEnded(self, reason):
self.log.info(
"pg_ctl process ended with status={status}",
status=reason.value.status
)
# If pg_ctl exited with zero, we were successful in starting postgres
# If pg_ctl exited with nonzero, we need to give up.
self.lineReceiver.connectionLost(reason)
if reason.value.status == 0:
self.completionDeferred.callback(None)
else:
self.log.error("Could not start postgres; see postgres.log")
self.completionDeferred.errback(reason)
示例5: _PostgresMonitor
# 需要导入模块: from twisted.protocols.basic import LineReceiver [as 别名]
# 或者: from twisted.protocols.basic.LineReceiver import connectionLost [as 别名]
class _PostgresMonitor(ProcessProtocol):
"""
A monitoring protocol which watches the postgres subprocess.
"""
def __init__(self, svc=None):
self.lineReceiver = LineReceiver()
self.lineReceiver.delimiter = '\n'
self.lineReceiver.lineReceived = self.lineReceived
self.svc = svc
self.isReady = False
self.completionDeferred = Deferred()
def lineReceived(self, line):
if self.svc is None:
return
if not self.isReady:
if _MAGIC_READY_COOKIE in line:
self.svc.ready()
disconnecting = False
def connectionMade(self):
self.lineReceiver.makeConnection(self)
def outReceived(self, out):
log.msg("received postgres stdout %r" % (out,))
# self.lineReceiver.dataReceived(out)
def errReceived(self, err):
log.msg("received postgres stderr %r" % (err,))
self.lineReceiver.dataReceived(err)
def processEnded(self, reason):
log.msg("postgres process ended %r" % (reason,))
result = (reason.value.status == 0)
self.lineReceiver.connectionLost(reason)
self.completionDeferred.callback(result)
示例6: connectionLost
# 需要导入模块: from twisted.protocols.basic import LineReceiver [as 别名]
# 或者: from twisted.protocols.basic.LineReceiver import connectionLost [as 别名]
def connectionLost(self, reason=connectionDone):
LineReceiver.connectionLost(self)
self.transport_connected = False
self.log("Transport disconnected")
示例7: connectionLost
# 需要导入模块: from twisted.protocols.basic import LineReceiver [as 别名]
# 或者: from twisted.protocols.basic.LineReceiver import connectionLost [as 别名]
def connectionLost(self, reason):
self.factory.unregisterConnection(self)
LineReceiver.connectionLost(self, reason)
示例8: connectionLost
# 需要导入模块: from twisted.protocols.basic import LineReceiver [as 别名]
# 或者: from twisted.protocols.basic.LineReceiver import connectionLost [as 别名]
def connectionLost(self, reason):
msg("Lost connection with: %s with ID %s" % (str(self.transport.getPeer()), self.id), logLevel=logging.DEBUG)
self.factory.unregisterConnection(self)
LineReceiver.connectionLost(self, reason)
示例9: connectionLost
# 需要导入模块: from twisted.protocols.basic import LineReceiver [as 别名]
# 或者: from twisted.protocols.basic.LineReceiver import connectionLost [as 别名]
def connectionLost(self, reason):
LineReceiver.connectionLost(self, reason)
print "connection lost"
示例10: connectionLost
# 需要导入模块: from twisted.protocols.basic import LineReceiver [as 别名]
# 或者: from twisted.protocols.basic.LineReceiver import connectionLost [as 别名]
def connectionLost(self, reason=connectionDone):
self.results_ready_deferred.callback(self.results)
LineReceiver.connectionLost(self, reason=reason)
示例11: connectionLost
# 需要导入模块: from twisted.protocols.basic import LineReceiver [as 别名]
# 或者: from twisted.protocols.basic.LineReceiver import connectionLost [as 别名]
def connectionLost(self, reason):
print "a client disconnected ..."
LineReceiver.connectionLost(self, reason)
self.factory.clients.remove(self)
示例12: connectionLost
# 需要导入模块: from twisted.protocols.basic import LineReceiver [as 别名]
# 或者: from twisted.protocols.basic.LineReceiver import connectionLost [as 别名]
def connectionLost(self, reason):
print "Network connection lost"
LineReceiver.connectionLost(self, reason)