def testSamePoolName(self): poolA = "A" pids = [] for pool in (poolA, poolA): proc = oop.getProcessPool(pool)._ioproc name = proc._commthread.getName() pids.append(int(re.search(r'\d+', name).group())) self.assertEquals(pids[0], pids[1])
def testDifferentPoolName(self): poolA = "A" poolB = "B" pools = (poolA, poolB) pids = [] for pool in pools: proc = oop.getProcessPool(pool)._ioproc name = proc._commthread.name pids.append(int(re.search(r'\d+', name).group())) self.assertNotEquals(pids[0], pids[1])
def testAmountOfInstancesPerPoolName(self): idle = oop.IOPROC_IDLE_TIME try: oop.IOPROC_IDLE_TIME = 5 poolA = "A" poolB = "B" wrapper = ref(oop.getProcessPool(poolA)) ioproc = ref(oop.getProcessPool(poolA)._ioproc) oop.getProcessPool(poolA) time.sleep(oop.IOPROC_IDLE_TIME + 1) oop.getProcessPool(poolB) self.assertEquals(wrapper(), None) gc.collect() time.sleep(1) gc.collect() try: self.assertEquals(ioproc(), None) except AssertionError: logging.info("GARBAGE: %s", gc.garbage) refs = gc.get_referrers(ioproc()) logging.info(refs) logging.info(gc.get_referrers(*refs)) raise finally: oop.IOPROC_IDLE_TIME = idle
def testAmountOfInstancesPerPoolName(self): with MonkeyPatchScope([(oop, 'IOPROC_IDLE_TIME', 5)]): poolA = "A" poolB = "B" wrapper = ref(oop.getProcessPool(poolA)) ioproc = ref(oop.getProcessPool(poolA)._ioproc) oop.getProcessPool(poolA) time.sleep(oop.IOPROC_IDLE_TIME + 1) oop.getProcessPool(poolB) self.assertEquals(wrapper(), None) gc.collect() time.sleep(1) gc.collect() try: self.assertEquals(ioproc(), None) except AssertionError: logging.info("GARBAGE: %s", gc.garbage) refs = gc.get_referrers(ioproc()) logging.info(refs) logging.info(gc.get_referrers(*refs)) raise
def oop(self): return outOfProcess.getProcessPool(self.sdUUID)