예제 #1
0
 def __getitem__(self, name):
     if name in self.keys():
         return super(CouchDBPoolDict, self).__getitem__(name)
     factory_method = lambda name: CouchStore(self.prefix + name, **self.
                                              db_args)
     pool = Pool(name, factory_method=factory_method, **self.pool_args)
     self.__setitem__(name, pool)
     return pool
예제 #2
0
파일: test_pool.py 프로젝트: swarbhanu/pyon
    def test_limit(self):
        subject = Pool('testpool',self._create_object, max_connections=3)

        # check out max
        for n in xrange(3):
            o = subject.check_out()
            self.assertTrue(o is not None)

        # should fail if try for one more
        try:
            o = subject.check_out()
            self.fail('should not checkout more than max')
        except:
            pass

        # return one, now can check out more
        subject.check_in(o)
        o2 = subject.check_out()
예제 #3
0
파일: test_pool.py 프로젝트: swarbhanu/pyon
    def test_check_out(self):
        subject = Pool('testpool',self._create_object)

        o1 = subject.check_out()
        o2 = subject.check_out()

        self.assertNotEqual(o1,o2)
        self.assertTrue(o1 in subject._used)
        self.assertFalse(o1 in subject._unused)

        subject.check_in(o1)
        self.assertFalse(o1 in subject._used)
        self.assertTrue(o1 in subject._unused)

        o3 = subject.check_out()
        self.assertEqual(o1,o3)