Beispiel #1
0
 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"))
Beispiel #2
0
 def connectionLost(self, reason):
     """
     Cause any outstanding commands to fail.
     """
     self._disconnected = True
     self._cancelCommands(reason)
     LineReceiver.connectionLost(self, reason)
Beispiel #3
0
 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"))
Beispiel #4
0
 def connectionLost(self, reason):
     """
     Cause any outstanding commands to fail.
     """
     self._disconnected = True
     self._cancelCommands(reason)
     LineReceiver.connectionLost(self, reason)
		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" 
Beispiel #6
0
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)
Beispiel #7
0
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.warn("received postgres stdout {out!r}", out=out)
        # self.lineReceiver.dataReceived(out)


    def errReceived(self, err):
        log.warn("received postgres stderr {err}", err=err)
        self.lineReceiver.dataReceived(err)


    def processEnded(self, reason):
        log.warn(
            "postgres 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:
            log.warn("Could not start postgres; see postgres.log")
            self.completionDeferred.errback(reason)
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)
Beispiel #9
0
 def connectionLost(self, reason):
     LineReceiver.connectionLost(self, reason)
     try:
         self.lc_ping.stop()
     except:
         pass
     print('pair: ', self.factory.pair)
     print('conn_list: ', self.factory.connection_list)
     print('peers: ', self.factory.peers)
     print('host_list:', self.factory.host_list)
     print('miner_list:', self.factory.miner_nodes)
     if self.miner_id in self.factory.miner_nodes:
         self.factory.miner_nodes.pop(self.miner_id)
         print('miner :', self.miner_id, ' disconnected')
     if self.remote_nodeid in self.factory.peers:
         host = self.factory.pair[self.remote_nodeid]
         self.factory.pair.pop(self.remote_nodeid)
         self.factory.peers.pop(self.remote_nodeid)
         self.factory.host_list.remove(host)
         self.factory.connection_list.remove(host)
         print(self.remote_nodeid, "disconnected")
     else:
         print(self.nodeid, 'disconnected')
Beispiel #10
0
 def connectionLost(self, reason):
     print "a client disconnected ..."
     LineReceiver.connectionLost(self, reason)
     self.factory.clients.remove(self)
Beispiel #11
0
 def connectionLost(self, reason):
     LineReceiver.connectionLost(self, reason)
     print "connection lost"
 def connectionLost(self, reason=connectionDone):
     self.results_ready_deferred.callback(self.results)
     LineReceiver.connectionLost(self, reason=reason)
Beispiel #13
0
 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)
Beispiel #14
0
    def connectionLost(self, reason=connectionDone):
        LineReceiver.connectionLost(self)
        self.transport_connected = False

        self.log("Transport disconnected")
Beispiel #15
0
 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)
Beispiel #16
0
 def connectionLost(self, reason):
     self.__factory.receivers.discard(self)
     LineReceiver.connectionLost(self, reason)
 def connectionLost(self, reason=connectionDone):
     self.results_ready_deferred.callback(self.results)
     LineReceiver.connectionLost(self, reason=reason)
Beispiel #18
0
 def connectionLost(self, reason):
     print "a client disconnected ..."
     LineReceiver.connectionLost(self, reason)
     self.factory.clients.remove(self)
Beispiel #19
0
 def connectionLost(self, reason):
     LineReceiver.connectionLost(self, reason)
     print "connection lost"
Beispiel #20
0
 def connectionLost(self, reason=connectionDone):
     self.sessions = {}
     LineReceiver.connectionLost(self, reason)
Beispiel #21
0
 def connectionLost(self, reason):
     self.factory.unregisterConnection(self)
     LineReceiver.connectionLost(self, reason)
Beispiel #22
0
 def connectionLost(self, reason=connectionDone):
     self._logger.debug("Lost connection with: %s with ID %s",
                        str(self.transport.getPeer()), self.id)
     self.factory.unregisterConnection(self)
     LineReceiver.connectionLost(self, reason)
Beispiel #23
0
 def connectionLost(self, reason):
     self.__factory.receivers.discard(self)
     logging.debug('disconnected')
     LineReceiver.connectionLost(self, reason)
Beispiel #24
0
 def connectionLost(self, reason):
     print "Network connection lost"
     LineReceiver.connectionLost(self, reason)