Exemplo n.º 1
0
 def packThemUp(values):
     serials = []
     for v in values:
         try:
             serials.append(newserialized.serialize(v))
         except:
             return defer.fail(failure.Failure())
     return serials
Exemplo n.º 2
0
 def packThemUp(values):
     serials = []
     for v in values:
         try:
             serials.append(newserialized.serialize(v))
         except:
             return defer.fail(failure.Failure())
     return serials
Exemplo n.º 3
0
 def testPushPullSerialized(self):
     objs = [10, "hi there", 1.2342354, {"p": (1, 2)}]
     d = defer.succeed(None)
     for o in objs:
         self.engine.push_serialized(dict(key=newserialized.serialize(o)))
         value = self.engine.pull_serialized("key")
         value.addCallback(lambda serial: newserialized.IUnSerialized(serial).getObject())
         d = self.assertDeferredEquals(value, o, d)
     return d
Exemplo n.º 4
0
 def testIEngineSerializedDeferreds(self):
     dList = []
     d = self.engine.push_serialized(dict(key=newserialized.serialize(12345)))
     self.assert_(isinstance(d, defer.Deferred))
     dList.append(d)
     d = self.engine.pull_serialized("key")
     self.assert_(isinstance(d, defer.Deferred))
     dList.append(d)
     D = defer.DeferredList(dList)
     return D
Exemplo n.º 5
0
 def testPushPullSerialized(self):
     objs = [10, "hi there", 1.2342354, {"p": (1, 2)}]
     d = defer.succeed(None)
     for o in objs:
         self.engine.push_serialized(dict(key=newserialized.serialize(o)))
         value = self.engine.pull_serialized('key')
         value.addCallback(
             lambda serial: newserialized.IUnSerialized(serial).getObject())
         d = self.assertDeferredEquals(value, o, d)
     return d
Exemplo n.º 6
0
 def testIEngineSerializedDeferreds(self):
     dList = []
     d = self.engine.push_serialized(
         dict(key=newserialized.serialize(12345)))
     self.assert_(isinstance(d, defer.Deferred))
     dList.append(d)
     d = self.engine.pull_serialized('key')
     self.assert_(isinstance(d, defer.Deferred))
     dList.append(d)
     D = defer.DeferredList(dList)
     return D
Exemplo n.º 7
0
 def testIEngineMultiplexerDeferreds(self):
     self.addEngine(1)
     d= self.multiengine.execute('a=5', targets=0)
     d.addCallback(lambda _: self.multiengine.push(dict(a=5),targets=0))
     d.addCallback(lambda _: self.multiengine.push(dict(a=5, b='asdf', c=[1,2,3]),targets=0))
     d.addCallback(lambda _: self.multiengine.pull(('a','b','c'),targets=0))
     d.addCallback(lambda _: self.multiengine.get_result(targets=0))
     d.addCallback(lambda _: self.multiengine.reset(targets=0))
     d.addCallback(lambda _: self.multiengine.keys(targets=0))
     d.addCallback(lambda _: self.multiengine.push_serialized(dict(a=newserialized.serialize(10)),targets=0))
     d.addCallback(lambda _: self.multiengine.pull_serialized('a',targets=0))
     d.addCallback(lambda _: self.multiengine.clear_queue(targets=0))
     d.addCallback(lambda _: self.multiengine.queue_status(targets=0))
     return d
Exemplo n.º 8
0
 def testIEngineMultiplexerDeferreds(self):
     self.addEngine(1)
     d= self.multiengine.execute('a=5', targets=0)
     d.addCallback(lambda _: self.multiengine.push(dict(a=5),targets=0))
     d.addCallback(lambda _: self.multiengine.push(dict(a=5, b='asdf', c=[1,2,3]),targets=0))
     d.addCallback(lambda _: self.multiengine.pull(('a','b','c'),targets=0))
     d.addCallback(lambda _: self.multiengine.get_result(targets=0))
     d.addCallback(lambda _: self.multiengine.reset(targets=0))
     d.addCallback(lambda _: self.multiengine.keys(targets=0))
     d.addCallback(lambda _: self.multiengine.push_serialized(dict(a=newserialized.serialize(10)),targets=0))
     d.addCallback(lambda _: self.multiengine.pull_serialized('a',targets=0))
     d.addCallback(lambda _: self.multiengine.clear_queue(targets=0))
     d.addCallback(lambda _: self.multiengine.queue_status(targets=0))
     return d
Exemplo n.º 9
0
    def testPushPullSerialized(self):
        self.addEngine(1)
        objs = [10,"hi there",1.2342354,{"p":(1,2)}]
        d= self.multiengine.push_serialized(dict(key=newserialized.serialize(objs[0])), targets=0)
        d.addCallback(lambda _: self.multiengine.pull_serialized('key', targets=0))
        d.addCallback(lambda serial: newserialized.IUnSerialized(serial[0]).getObject())
        d.addCallback(lambda r: self.assertEquals(r, objs[0]))
        d.addCallback(lambda _: self.multiengine.push_serialized(dict(key=newserialized.serialize(objs[1])), targets=0))
        d.addCallback(lambda _: self.multiengine.pull_serialized('key', targets=0))
        d.addCallback(lambda serial: newserialized.IUnSerialized(serial[0]).getObject())
        d.addCallback(lambda r: self.assertEquals(r, objs[1]))
        d.addCallback(lambda _: self.multiengine.push_serialized(dict(key=newserialized.serialize(objs[2])), targets=0))
        d.addCallback(lambda _: self.multiengine.pull_serialized('key', targets=0))
        d.addCallback(lambda serial: newserialized.IUnSerialized(serial[0]).getObject())
        d.addCallback(lambda r: self.assertEquals(r, objs[2]))
        d.addCallback(lambda _: self.multiengine.push_serialized(dict(key=newserialized.serialize(objs[3])), targets=0))
        d.addCallback(lambda _: self.multiengine.pull_serialized('key', targets=0))
        d.addCallback(lambda serial: newserialized.IUnSerialized(serial[0]).getObject())
        d.addCallback(lambda r: self.assertEquals(r, objs[3]))
        d.addCallback(lambda _: self.multiengine.push(dict(a=10,b=list(range(5))), targets=0))
        d.addCallback(lambda _: self.multiengine.pull_serialized(('a','b'), targets=0))
        d.addCallback(lambda serial: [newserialized.IUnSerialized(s).getObject() for s in serial[0]])
        d.addCallback(lambda r: self.assertEquals(r, [10, list(range(5))]))
        d.addCallback(lambda _: self.multiengine.reset(targets=0))
        d.addCallback(lambda _: self.multiengine.pull_serialized('a', targets=0))
        d.addErrback(lambda f: self.assertRaises(NameError, _raise_it, f))
        return d

        objs = [10,"hi there",1.2342354,{"p":(1,2)}]
        d= defer.succeed(None)
        for o in objs:
            self.multiengine.push_serialized(0, key=newserialized.serialize(o))
            value = self.multiengine.pull_serialized(0, 'key')
            value.addCallback(lambda serial: newserialized.IUnSerialized(serial[0]).getObject())
            d = self.assertDeferredEquals(value,o,d)
        return d
Exemplo n.º 10
0
    def testPushPullSerialized(self):
        self.addEngine(1)
        objs = [10,"hi there",1.2342354,{"p":(1,2)}]
        d= self.multiengine.push_serialized(dict(key=newserialized.serialize(objs[0])), targets=0)
        d.addCallback(lambda _: self.multiengine.pull_serialized('key', targets=0))
        d.addCallback(lambda serial: newserialized.IUnSerialized(serial[0]).getObject())
        d.addCallback(lambda r: self.assertEquals(r, objs[0]))
        d.addCallback(lambda _: self.multiengine.push_serialized(dict(key=newserialized.serialize(objs[1])), targets=0))
        d.addCallback(lambda _: self.multiengine.pull_serialized('key', targets=0))
        d.addCallback(lambda serial: newserialized.IUnSerialized(serial[0]).getObject())
        d.addCallback(lambda r: self.assertEquals(r, objs[1]))
        d.addCallback(lambda _: self.multiengine.push_serialized(dict(key=newserialized.serialize(objs[2])), targets=0))
        d.addCallback(lambda _: self.multiengine.pull_serialized('key', targets=0))
        d.addCallback(lambda serial: newserialized.IUnSerialized(serial[0]).getObject())
        d.addCallback(lambda r: self.assertEquals(r, objs[2]))
        d.addCallback(lambda _: self.multiengine.push_serialized(dict(key=newserialized.serialize(objs[3])), targets=0))
        d.addCallback(lambda _: self.multiengine.pull_serialized('key', targets=0))
        d.addCallback(lambda serial: newserialized.IUnSerialized(serial[0]).getObject())
        d.addCallback(lambda r: self.assertEquals(r, objs[3]))
        d.addCallback(lambda _: self.multiengine.push(dict(a=10,b=range(5)), targets=0))
        d.addCallback(lambda _: self.multiengine.pull_serialized(('a','b'), targets=0))
        d.addCallback(lambda serial: [newserialized.IUnSerialized(s).getObject() for s in serial[0]])
        d.addCallback(lambda r: self.assertEquals(r, [10, range(5)]))
        d.addCallback(lambda _: self.multiengine.reset(targets=0))
        d.addCallback(lambda _: self.multiengine.pull_serialized('a', targets=0))
        d.addErrback(lambda f: self.assertRaises(NameError, _raise_it, f))
        return d

        objs = [10,"hi there",1.2342354,{"p":(1,2)}]
        d= defer.succeed(None)
        for o in objs:
            self.multiengine.push_serialized(0, key=newserialized.serialize(o))
            value = self.multiengine.pull_serialized(0, 'key')
            value.addCallback(lambda serial: newserialized.IUnSerialized(serial[0]).getObject())
            d = self.assertDeferredEquals(value,o,d)
        return d
Exemplo n.º 11
0
 def testInvalidEngineID(self):
      self.addEngine(1)
      badID = 100
      d = self.multiengine.execute('a=5', targets=badID)
      d.addErrback(lambda f: self.assertRaises(InvalidEngineID, f.raiseException))
      d.addCallback(lambda _: self.multiengine.push(dict(a=5), targets=badID))
      d.addErrback(lambda f: self.assertRaises(InvalidEngineID, f.raiseException))
      d.addCallback(lambda _: self.multiengine.pull('a', targets=badID))
      d.addErrback(lambda f: self.assertRaises(InvalidEngineID, f.raiseException))
      d.addCallback(lambda _: self.multiengine.reset(targets=badID))
      d.addErrback(lambda f: self.assertRaises(InvalidEngineID, f.raiseException))
      d.addCallback(lambda _: self.multiengine.keys(targets=badID))
      d.addErrback(lambda f: self.assertRaises(InvalidEngineID, f.raiseException))
      d.addCallback(lambda _: self.multiengine.push_serialized(dict(a=newserialized.serialize(10)), targets=badID))
      d.addErrback(lambda f: self.assertRaises(InvalidEngineID, f.raiseException))
      d.addCallback(lambda _: self.multiengine.pull_serialized('a', targets=badID))
      d.addErrback(lambda f: self.assertRaises(InvalidEngineID, f.raiseException))
      d.addCallback(lambda _: self.multiengine.queue_status(targets=badID))
      d.addErrback(lambda f: self.assertRaises(InvalidEngineID, f.raiseException))
      return d
Exemplo n.º 12
0
 def testInvalidEngineID(self):
      self.addEngine(1)
      badID = 100
      d = self.multiengine.execute('a=5', targets=badID)
      d.addErrback(lambda f: self.assertRaises(InvalidEngineID, f.raiseException))
      d.addCallback(lambda _: self.multiengine.push(dict(a=5), targets=badID))
      d.addErrback(lambda f: self.assertRaises(InvalidEngineID, f.raiseException))
      d.addCallback(lambda _: self.multiengine.pull('a', targets=badID))
      d.addErrback(lambda f: self.assertRaises(InvalidEngineID, f.raiseException))
      d.addCallback(lambda _: self.multiengine.reset(targets=badID))
      d.addErrback(lambda f: self.assertRaises(InvalidEngineID, f.raiseException))
      d.addCallback(lambda _: self.multiengine.keys(targets=badID))
      d.addErrback(lambda f: self.assertRaises(InvalidEngineID, f.raiseException))
      d.addCallback(lambda _: self.multiengine.push_serialized(dict(a=newserialized.serialize(10)), targets=badID))
      d.addErrback(lambda f: self.assertRaises(InvalidEngineID, f.raiseException))
      d.addCallback(lambda _: self.multiengine.pull_serialized('a', targets=badID))
      d.addErrback(lambda f: self.assertRaises(InvalidEngineID, f.raiseException))
      d.addCallback(lambda _: self.multiengine.queue_status(targets=badID))
      d.addErrback(lambda f: self.assertRaises(InvalidEngineID, f.raiseException))
      return d
Exemplo n.º 13
0
 def testNoEnginesRegistered(self):
     badID = 'all'
     d= self.multiengine.execute('a=5', targets=badID)
     d.addErrback(lambda f: self.assertRaises(NoEnginesRegistered, f.raiseException))
     d.addCallback(lambda _: self.multiengine.push(dict(a=5), targets=badID))
     d.addErrback(lambda f: self.assertRaises(NoEnginesRegistered, f.raiseException))
     d.addCallback(lambda _: self.multiengine.pull('a', targets=badID))
     d.addErrback(lambda f: self.assertRaises(NoEnginesRegistered, f.raiseException))
     d.addCallback(lambda _: self.multiengine.get_result(targets=badID))
     d.addErrback(lambda f: self.assertRaises(NoEnginesRegistered, f.raiseException))
     d.addCallback(lambda _: self.multiengine.reset(targets=badID))
     d.addErrback(lambda f: self.assertRaises(NoEnginesRegistered, f.raiseException))
     d.addCallback(lambda _: self.multiengine.keys(targets=badID))
     d.addErrback(lambda f: self.assertRaises(NoEnginesRegistered, f.raiseException))
     d.addCallback(lambda _: self.multiengine.push_serialized(dict(a=newserialized.serialize(10)), targets=badID))
     d.addErrback(lambda f: self.assertRaises(NoEnginesRegistered, f.raiseException))
     d.addCallback(lambda _: self.multiengine.pull_serialized('a', targets=badID))
     d.addErrback(lambda f: self.assertRaises(NoEnginesRegistered, f.raiseException))
     d.addCallback(lambda _: self.multiengine.queue_status(targets=badID))
     d.addErrback(lambda f: self.assertRaises(NoEnginesRegistered, f.raiseException))
     return d
Exemplo n.º 14
0
 def testNoEnginesRegistered(self):
     badID = 'all'
     d= self.multiengine.execute('a=5', targets=badID)
     d.addErrback(lambda f: self.assertRaises(NoEnginesRegistered, f.raiseException))
     d.addCallback(lambda _: self.multiengine.push(dict(a=5), targets=badID))
     d.addErrback(lambda f: self.assertRaises(NoEnginesRegistered, f.raiseException))
     d.addCallback(lambda _: self.multiengine.pull('a', targets=badID))
     d.addErrback(lambda f: self.assertRaises(NoEnginesRegistered, f.raiseException))
     d.addCallback(lambda _: self.multiengine.get_result(targets=badID))
     d.addErrback(lambda f: self.assertRaises(NoEnginesRegistered, f.raiseException))
     d.addCallback(lambda _: self.multiengine.reset(targets=badID))
     d.addErrback(lambda f: self.assertRaises(NoEnginesRegistered, f.raiseException))
     d.addCallback(lambda _: self.multiengine.keys(targets=badID))
     d.addErrback(lambda f: self.assertRaises(NoEnginesRegistered, f.raiseException))
     d.addCallback(lambda _: self.multiengine.push_serialized(dict(a=newserialized.serialize(10)), targets=badID))
     d.addErrback(lambda f: self.assertRaises(NoEnginesRegistered, f.raiseException))
     d.addCallback(lambda _: self.multiengine.pull_serialized('a', targets=badID))
     d.addErrback(lambda f: self.assertRaises(NoEnginesRegistered, f.raiseException))
     d.addCallback(lambda _: self.multiengine.queue_status(targets=badID))
     d.addErrback(lambda f: self.assertRaises(NoEnginesRegistered, f.raiseException))
     return d
Exemplo n.º 15
0
    def testPushPullSerialized(self):
        self.addEngine(1)
        dikt = dict(a=10,b='hi there',c=1.2345,d={'p':(1,2)})
        sdikt = {}
        for k,v in dikt.items():
            sdikt[k] = newserialized.serialize(v)
        d= self.multiengine.push_serialized(dict(a=sdikt['a']), targets=0)
        d.addCallback(lambda _: self.multiengine.pull('a',targets=0))
        d.addCallback(lambda r: self.assertEquals(r[0], dikt['a']))
        d.addCallback(lambda _: self.multiengine.pull_serialized('a', targets=0))
        d.addCallback(lambda serial: newserialized.IUnSerialized(serial[0]).getObject())
        d.addCallback(lambda r: self.assertEquals(r, dikt['a']))
        d.addCallback(lambda _: self.multiengine.push_serialized(sdikt, targets=0))
        d.addCallback(lambda _: self.multiengine.pull_serialized(list(sdikt.keys()), targets=0))
        d.addCallback(lambda serial: [newserialized.IUnSerialized(s).getObject() for s in serial[0]])
        d.addCallback(lambda r: self.assertEquals(r, list(dikt.values())))
        d.addCallback(lambda _: self.multiengine.reset(targets=0))
        d.addCallback(lambda _: self.multiengine.pull_serialized('a', targets=0))
        d.addErrback(lambda f: self.assertRaises(NameError, _raise_it, f))

        #Non-blocking mode
        d.addCallback(lambda r: self.multiengine.push_serialized(dict(a=sdikt['a']), targets=0, block=False))
        d.addCallback(lambda did: self.multiengine.get_pending_deferred(did, True))
        d.addCallback(lambda _: self.multiengine.pull('a',targets=0))
        d.addCallback(lambda r: self.assertEquals(r[0], dikt['a']))
        d.addCallback(lambda _: self.multiengine.pull_serialized('a', targets=0, block=False))
        d.addCallback(lambda did: self.multiengine.get_pending_deferred(did, True))
        d.addCallback(lambda serial: newserialized.IUnSerialized(serial[0]).getObject())
        d.addCallback(lambda r: self.assertEquals(r, dikt['a']))
        d.addCallback(lambda _: self.multiengine.push_serialized(sdikt, targets=0, block=False))
        d.addCallback(lambda did: self.multiengine.get_pending_deferred(did, True))
        d.addCallback(lambda _: self.multiengine.pull_serialized(list(sdikt.keys()), targets=0, block=False))
        d.addCallback(lambda did: self.multiengine.get_pending_deferred(did, True))
        d.addCallback(lambda serial: [newserialized.IUnSerialized(s).getObject() for s in serial[0]])
        d.addCallback(lambda r: self.assertEquals(r, list(dikt.values())))
        d.addCallback(lambda _: self.multiengine.reset(targets=0))
        d.addCallback(lambda _: self.multiengine.pull_serialized('a', targets=0, block=False))
        d.addCallback(lambda did: self.multiengine.get_pending_deferred(did, True))
        d.addErrback(lambda f: self.assertRaises(NameError, _raise_it, f))
        return d
Exemplo n.º 16
0
    def testPushPullSerialized(self):
        self.addEngine(1)
        dikt = dict(a=10,b='hi there',c=1.2345,d={'p':(1,2)})
        sdikt = {}
        for k,v in dikt.iteritems():
            sdikt[k] = newserialized.serialize(v)
        d= self.multiengine.push_serialized(dict(a=sdikt['a']), targets=0)
        d.addCallback(lambda _: self.multiengine.pull('a',targets=0))
        d.addCallback(lambda r: self.assertEquals(r[0], dikt['a']))
        d.addCallback(lambda _: self.multiengine.pull_serialized('a', targets=0))
        d.addCallback(lambda serial: newserialized.IUnSerialized(serial[0]).getObject())
        d.addCallback(lambda r: self.assertEquals(r, dikt['a']))
        d.addCallback(lambda _: self.multiengine.push_serialized(sdikt, targets=0))
        d.addCallback(lambda _: self.multiengine.pull_serialized(sdikt.keys(), targets=0))
        d.addCallback(lambda serial: [newserialized.IUnSerialized(s).getObject() for s in serial[0]])
        d.addCallback(lambda r: self.assertEquals(r, dikt.values()))
        d.addCallback(lambda _: self.multiengine.reset(targets=0))
        d.addCallback(lambda _: self.multiengine.pull_serialized('a', targets=0))
        d.addErrback(lambda f: self.assertRaises(NameError, _raise_it, f))

        #Non-blocking mode
        d.addCallback(lambda r: self.multiengine.push_serialized(dict(a=sdikt['a']), targets=0, block=False))
        d.addCallback(lambda did: self.multiengine.get_pending_deferred(did, True))
        d.addCallback(lambda _: self.multiengine.pull('a',targets=0))
        d.addCallback(lambda r: self.assertEquals(r[0], dikt['a']))
        d.addCallback(lambda _: self.multiengine.pull_serialized('a', targets=0, block=False))
        d.addCallback(lambda did: self.multiengine.get_pending_deferred(did, True))
        d.addCallback(lambda serial: newserialized.IUnSerialized(serial[0]).getObject())
        d.addCallback(lambda r: self.assertEquals(r, dikt['a']))
        d.addCallback(lambda _: self.multiengine.push_serialized(sdikt, targets=0, block=False))
        d.addCallback(lambda did: self.multiengine.get_pending_deferred(did, True))
        d.addCallback(lambda _: self.multiengine.pull_serialized(sdikt.keys(), targets=0, block=False))
        d.addCallback(lambda did: self.multiengine.get_pending_deferred(did, True))
        d.addCallback(lambda serial: [newserialized.IUnSerialized(s).getObject() for s in serial[0]])
        d.addCallback(lambda r: self.assertEquals(r, dikt.values()))
        d.addCallback(lambda _: self.multiengine.reset(targets=0))
        d.addCallback(lambda _: self.multiengine.pull_serialized('a', targets=0, block=False))
        d.addCallback(lambda did: self.multiengine.get_pending_deferred(did, True))
        d.addErrback(lambda f: self.assertRaises(NameError, _raise_it, f))
        return d