Пример #1
0
 def handleNamespacePulled(self, namespace):
     serialNS = {}
     try:
         for k,v in namespace.iteritems():
             serialNS[k] = serialized.serialize(v, k)
     except Exception, e:
         self.dieLoudly("serialization error: ", e)
 def testPushPullSerialized(self):
     objs = [10, "hi there", 1.2342354, {"p": (1, 2)}]
     d = defer.succeed(None)
     for o in objs:
         self.engine.pushSerialized(key=serialized.serialize(o, 'key'))
         value = self.engine.pullSerialized('key')
         value.addCallback(lambda serial: serial.unpack())
         d = self.assertDeferredEquals(value, o, d)
     return d
Пример #3
0
 def isPushReady(self, msg):
     if msg == 'READY':
         for k, v in self.workVars['namespace'].iteritems():
             try:
                 s = serialized.serialize(v, k)
             except Exception, e:
                 log.msg('You tried to push an unserializable type, ignoring: ' + k) 
             else:
                 self.sendSerialized(s)
         self.finishPush()
Пример #4
0
 def isPushReady(self, msg):
     if msg == 'READY':
         for k, v in self.workVars['namespace'].iteritems():
             try:
                 s = serialized.serialize(v, k)
             except Exception, e:
                 log.msg('You tried to push an unserializable type, ignoring: ' + k) 
             else:
                 # This is where the Serialized gets sent.  Here we should
                 # put the Serialized into an IProducer and register it using
                 # self.transport.registerProducer(foo)
                 self.sendSerialized(s)
         self.finishPush()
Пример #5
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)
    def testCompletedEmptyEngine(self):
        class Empty:
            pass

        ni = NotImplementedError
        c = es.completeEngine(Empty())
        d = self.assertDeferredRaises(c.execute('a=5'), ni)
        d = self.assertDeferredRaises(c.push(a=5), ni, d)
        d = self.assertDeferredRaises(
            c.pushSerialized(a=serialized.serialize([1, 2, 'a'], 'a')), ni, d)
        d = self.assertDeferredRaises(c.pull('a', 'b', 'c'), ni, d)
        d = self.assertDeferredRaises(c.pullSerialized('a', 'b', 'c'), ni, d)
        d = self.assertDeferredRaises(c.pullNamespace('qwer', 'asdf', 'zcxv'),
                                      ni, d)
        d = self.assertDeferredRaises(c.getResult(), ni, d)
        d = self.assertDeferredRaises(c.reset(), ni, d)
        d = self.assertDeferredRaises(c.status(), ni, d)
        d = self.assertDeferredRaises(c.clearQueue(), ni, d)
        return self.assertEquals(c.id, None, d)
Пример #7
0
 def statusOK(self, args):
     serial = serialized.serialize(args, 'STATUS')
     self.sendSerialized(serial)
     self._reset()
     self.sendString('STATUS OK')
Пример #8
0
 def handlePullProblems(self, reason):
     return serialized.serialize(reason, 'FAILURE')