Exemple #1
0
    def connectionLost(self, reason):
        if isinstance(reason.value, ConnectionDone):
            self.log.info("Native worker connection closed cleanly.")
        else:
            self.log.warn("Native worker connection closed uncleanly: {reason}", reason=reason.value)

        WampWebSocketClientProtocol.connectionLost(self, reason)
        self.factory.proto = None

        if isinstance(reason.value, ProcessTerminated):
            if not self.factory._on_ready.called:
                # the worker was never ready in the first place ..
                self.factory._on_ready.errback(reason)
            else:
                # the worker _did_ run (was ready before), but now exited with error
                if not self.factory._on_exit.called:
                    self.factory._on_exit.errback(reason)
                else:
                    self.log.error("unhandled code path (1) in WorkerClientProtocol.connectionLost: {reason}", reason=reason.value)
        elif isinstance(reason.value, (ProcessDone, ConnectionDone)):
            # the worker exited cleanly
            if not self.factory._on_exit.called:
                self.factory._on_exit.callback(None)
            else:
                self.log.error("unhandled code path (2) in WorkerClientProtocol.connectionLost: {reason}", reason=reason.value)
        else:
            # should not arrive here
            self.log.error("unhandled code path (3) in WorkerClientProtocol.connectionLost: {reason}", reason=reason.value)
Exemple #2
0
         def connectionLost(self, reason):
            WampWebSocketClientProtocol.connectionLost(self, reason)
            self.factory.proto = None

            log.msg("Worker {}: Process connection gone ({})".format(self._pid, reason.value))

            if isinstance(reason.value, ProcessTerminated):
               if not ready.called:
                  ## the worker was never ready in the first place ..
                  ready.errback(reason)
               else:
                  ## the worker _did_ run (was ready before), but now exited with error
                  if not exit.called:
                     exit.errback(reason)
                  else:
                     log.msg("FIXME: unhandled code path (1) in WorkerClientProtocol.connectionLost", reason.value)
            elif isinstance(reason.value, ProcessDone) or isinstance(reason.value, ConnectionDone):
               ## the worker exited cleanly
               if not exit.called:
                  exit.callback()
               else:
                  log.msg("FIXME: unhandled code path (2) in WorkerClientProtocol.connectionLost", reason.value)
            else:
               ## should not arrive here
               log.msg("FIXME: unhandled code path (3) in WorkerClientProtocol.connectionLost", reason.value)
Exemple #3
0
    def connectionLost(self, reason):
        log.msg("Worker {}: Process connection gone ({})".format(
            self._pid, reason.value))

        WampWebSocketClientProtocol.connectionLost(self, reason)
        self.factory.proto = None

        if isinstance(reason.value, ProcessTerminated):
            if not self.factory._on_ready.called:
                ## the worker was never ready in the first place ..
                self.factory._on_ready.errback(reason)
            else:
                ## the worker _did_ run (was ready before), but now exited with error
                if not self.factory._on_exit.called:
                    self.factory._on_exit.errback(reason)
                else:
                    log.msg(
                        "FIXME: unhandled code path (1) in WorkerClientProtocol.connectionLost",
                        reason.value)
        elif isinstance(reason.value, ProcessDone) or isinstance(
                reason.value, ConnectionDone):
            ## the worker exited cleanly
            if not self.factory._on_exit.called:
                self.factory._on_exit.callback(None)
            else:
                log.msg(
                    "FIXME: unhandled code path (2) in WorkerClientProtocol.connectionLost",
                    reason.value)
        else:
            ## should not arrive here
            log.msg(
                "FIXME: unhandled code path (3) in WorkerClientProtocol.connectionLost",
                reason.value)
Exemple #4
0
    def connectionLost(self, reason):
        self.log.warn("Process connection gone: {reason}", reason=reason.value)

        WampWebSocketClientProtocol.connectionLost(self, reason)
        self.factory.proto = None

        if isinstance(reason.value, ProcessTerminated):
            if not self.factory._on_ready.called:
                # the worker was never ready in the first place ..
                self.factory._on_ready.errback(reason)
            else:
                # the worker _did_ run (was ready before), but now exited with error
                if not self.factory._on_exit.called:
                    self.factory._on_exit.errback(reason)
                else:
                    self.log.error("unhandled code path (1) in WorkerClientProtocol.connectionLost: {reason}", reason=reason.value)
        elif isinstance(reason.value, ProcessDone) or isinstance(reason.value, ConnectionDone):
            # the worker exited cleanly
            if not self.factory._on_exit.called:
                self.factory._on_exit.callback(None)
            else:
                self.log.error("unhandled code path (2) in WorkerClientProtocol.connectionLost: {reason}", reason=reason.value)
        else:
            # should not arrive here
            self.log.error("unhandled code path (3) in WorkerClientProtocol.connectionLost: {reason}", reason=reason.value)
Exemple #5
0
    def connectionMade(self):
        WampWebSocketClientProtocol.connectionMade(self)
        self._pid = self.transport.pid
        self.factory.proto = self

        # native workers are implicitly trusted
        self._authid = u'dummy'
        self._authrole = u'trusted'
        self._authmethod = u'trusted'

        # FIXME
        self._transport_info = None
Exemple #6
0
    def connectionMade(self):
        WampWebSocketClientProtocol.connectionMade(self)
        self._pid = self.transport.pid
        self.factory.proto = self

        # native workers are implicitly trusted
        self._authid = u'dummy'
        self._authrole = u'trusted'
        self._authmethod = u'trusted'

        # FIXME
        self._transport_info = None
Exemple #7
0
    def connectionMade(self):
        WampWebSocketClientProtocol.connectionMade(self)
        self._pid = self.transport.pid
        self.factory.proto = self

        # native workers are implicitly trusted
        self._authid = 'crossbar.process.{}'.format(self._pid)
        self._authrole = self.factory._authrole

        # the worker is actively spawned by the node controller,
        # and we talk over the pipes that were create during
        # process creation. this established implicit trust.
        self._authmethod = 'trusted'

        # the trust is established implicitly by the way the
        # the client (worker) is created
        self._authprovider = 'programcode'
Exemple #8
0
    def connectionMade(self):
        WampWebSocketClientProtocol.connectionMade(self)
        self._pid = self.transport.pid
        self.factory.proto = self

        # native workers are implicitly trusted
        self._authid = u'crossbar.process.{}'.format(self._pid)
        self._authrole = self.factory._authrole

        # the worker is actively spawned by the node controller,
        # and we talk over the pipes that were create during
        # process creation. this established implicit trust.
        self._authmethod = u'trusted'

        # the trust is established implicitly by the way the
        # the client (worker) is created
        self._authprovider = u'programcode'

        # FIXME / CHECKME
        self._cbtid = None
        self._transport_info = None
 def sendMessage(self, payload, isBinary):
     self.txcnt += 1
     print("> : {0:>3} : {1:<20} : {3}".format(
         self.txcnt, Klass.__name__, payload))
     WampWebSocketClientProtocol.sendMessage(
         self, payload, isBinary)
 def onMessage(self, bytes, isBinary):
     self.rxcnt += 1
     print("< : {:>3} : {:<20} : {}".format(
         self.rxcnt, Klass.__name__, bytes))
     WampWebSocketClientProtocol.onMessage(
         self, bytes, isBinary)
 def onOpen(self):
     self.txcnt = 0
     self.rxcnt = 0
     WampWebSocketClientProtocol.onOpen(self)
 def onMessage(self, payload, isBinary):
    self.rxcnt += 1
    print("< : {0:>3} : {1:<20} : {2}".format(self.rxcnt, Klass.__name__, payload))
    WampWebSocketClientProtocol.onMessage(self, payload, isBinary)
 def sendMessage(self, payload, isBinary):
    self.txcnt += 1
    print("> : {0:>3} : {1:<20} : {3}".format(self.txcnt, Klass.__name__, payload))
    WampWebSocketClientProtocol.sendMessage(self, payload, isBinary)
 def onOpen(self):
    self.txcnt = 0
    self.rxcnt = 0
    WampWebSocketClientProtocol.onOpen(self)
 def onMessage(self, payload, isBinary):
     self.rxcnt += 1
     print("< : {0:>3} : {1:<20} : {2}".format(
         self.rxcnt, Klass.__name__, payload))
     WampWebSocketClientProtocol.onMessage(
         self, payload, isBinary)
 def onMessage(self, bytes, isBinary):
    self.rxcnt += 1
    print("< : {:>3} : {:<20} : {}".format(self.rxcnt, Klass.__name__, bytes))
    WampWebSocketClientProtocol.onMessage(self, bytes, isBinary)
Exemple #17
0
 def connectionMade(self):
     WampWebSocketClientProtocol.connectionMade(self)
     self._pid = self.transport.pid
     self.factory.proto = self
Exemple #18
0
 def connectionMade(self):
     WampWebSocketClientProtocol.connectionMade(self)
     self._pid = self.transport.pid
     self.factory.proto = self