Ejemplo n.º 1
0
 def sendSerialized(self, s):
     maxlen = max(map(len, [line for line in s]))
     if maxlen > self.MAX_LENGTH:
         raise protocols.MessageSizeError(s.key)
     
     if isinstance(s, serialized.PickleSerialized):
         self.sendPickleSerialized(s)
     elif isinstance(s, serialized.ArraySerialized):
         self.sendArraySerialized(s)
Ejemplo n.º 2
0
    def checkSize(self, package):
        """Check the outgoiing size of the package. 
        
        If it is greater than self.MAX_LENGTH, replace with a 
        Failure pointing to a MessageSizeError.
        """

        if len(package) > self.MAX_LENGTH:
            package = pickle.dumps(Failure(protocols.MessageSizeError()), 2)
        return package
Ejemplo n.º 3
0
 def sendSerialized(self, s):
     maxlen = max(map(len, [line for line in s]))
     if maxlen > self.MAX_LENGTH:
         e = protocols.MessageSizeError(s.key)
         f = serialized.serialize(Failure(e), 'FAILURE')
         maxlen = max(map(len, [line for line in f]))
         if maxlen > self.MAX_LENGTH:
             return self.dieLoudly(e)
         return self.sendSerialized(f)
     
     if isinstance(s, serialized.PickleSerialized):
         self.sendPickleSerialized(s)
     elif isinstance(s, serialized.ArraySerialized):
         self.sendArraySerialized(s)
Ejemplo n.º 4
0
 def pushSerialized(self, **namespace):
     package = pickle.dumps(namespace, 2)
     if not self.checkSize(package):
         return defer.fail(Failure(protocols.MessageSizeError()))
     d = self.callRemote('pushSerialized', package)
     return d.addCallback(self.checkReturn)
Ejemplo n.º 5
0
 def execute(self, lines):
     if not self.checkSize(lines):
         return defer.fail(Failure(protocols.MessageSizeError()))
     return self.callRemote('execute', lines).addCallback(self.checkReturn)