Esempio n. 1
0
class RPyCProtocol(protocol.Protocol):
    """
    RPyC twisted protocol - feeds data into a TwistedSocketStream instance
    which is read out by RPyC.performing
    """
    def __init__(self, service):
        self.service = service

    def connectionMade(self):
        self._sockstream = TwistedSocketStream(self)
        self._channel = Channel(self._sockstream)
        self._connection = Connection(self.service, self._channel, _lazy=True)
        self._connection._init_service()

    def connectionLost(self, reason):
        if hasattr(self, "_connection"):
            self._connection.close()

    def dataReceived(self, data):
        # Spoof synchronous incoming data:
        self._sockstream.dataReceived(data)
        # Do the rest of our processing in a separate thread so
        # we don't block the reactor:
        threads.deferToThread(self._connection.serve, 1)
Esempio n. 2
0
 def close(self, *args):
     try:
         Connection.close(self, *args)
     finally:
         for lock in self._sync_events.itervalues():
             lock.set()
Esempio n. 3
0
 def close(self, *args):
     try:
         Connection.close(self, *args)
     finally:
         for lock in self._sync_events.itervalues():
             lock.set()