3 from db_test import DBDakTestCase
5 from daklib.dbconn import DBConn
7 from multiprocessing import Pool
12 session = DBConn().session()
13 result = session.query('foo').from_statement('select 7 as foo').scalar()
18 class MultiProcTestCase(DBDakTestCase):
20 This TestCase checks that DBConn works with multiprocessing.
23 def save_result(self, result):
28 Test apply_async() with a database session.
32 pool.apply_async(read_number, (), callback = self.save_result)
33 pool.apply_async(read_number, (), callback = self.save_result)
34 pool.apply_async(read_number, (), callback = self.save_result)
35 pool.apply_async(read_number, (), callback = self.save_result)
36 pool.apply_async(read_number, (), callback = self.save_result)
39 self.assertEqual(5 * 7, self.result)
41 if __name__ == '__main__':