(self)
| 1613 | pass |
| 1614 | |
| 1615 | def test_notify(self): |
| 1616 | cond = self.Condition() |
| 1617 | sleeping = self.Semaphore(0) |
| 1618 | woken = self.Semaphore(0) |
| 1619 | |
| 1620 | p = self.Process(target=self.f, args=(cond, sleeping, woken)) |
| 1621 | p.daemon = True |
| 1622 | p.start() |
| 1623 | |
| 1624 | t = threading.Thread(target=self.f, args=(cond, sleeping, woken)) |
| 1625 | t.daemon = True |
| 1626 | t.start() |
| 1627 | |
| 1628 | # wait for both children to start sleeping |
| 1629 | sleeping.acquire() |
| 1630 | sleeping.acquire() |
| 1631 | |
| 1632 | # check no process/thread has woken up |
| 1633 | self.assertReachesEventually(lambda: get_value(woken), 0) |
| 1634 | |
| 1635 | # wake up one process/thread |
| 1636 | cond.acquire() |
| 1637 | cond.notify() |
| 1638 | cond.release() |
| 1639 | |
| 1640 | # check one process/thread has woken up |
| 1641 | self.assertReachesEventually(lambda: get_value(woken), 1) |
| 1642 | |
| 1643 | # wake up another |
| 1644 | cond.acquire() |
| 1645 | cond.notify() |
| 1646 | cond.release() |
| 1647 | |
| 1648 | # check other has woken up |
| 1649 | self.assertReachesEventually(lambda: get_value(woken), 2) |
| 1650 | |
| 1651 | # check state is not mucked up |
| 1652 | self.check_invariant(cond) |
| 1653 | |
| 1654 | threading_helper.join_thread(t) |
| 1655 | join_process(p) |
| 1656 | |
| 1657 | def test_notify_all(self): |
| 1658 | cond = self.Condition() |
nothing calls this directly
no test coverage detected