def test_twoThreads(self): lock = thread.allocate_lock() topConnection.push(2) def x(): try: self.assertTrue(topConnection.isEmpty()) topConnection.push(1) finally: lock.release() lock.acquire() thread.start_new(x, ()) self.assertEquals(topConnection.top(), 2)
def x(): try: self.assertTrue(topConnection.isEmpty()) topConnection.push(1) finally: lock.release()
def __enter__(self): topConnection.push(self)