(self)
| 1770 | |
| 1771 | @client_context.require_sync |
| 1772 | def test_reset_during_update_pool(self): |
| 1773 | client = self.rs_or_single_client(minPoolSize=10) |
| 1774 | client.admin.command("ping") |
| 1775 | pool = get_pool(client) |
| 1776 | generation = pool.gen.get_overall() |
| 1777 | |
| 1778 | # Continuously reset the pool. |
| 1779 | class ResetPoolThread(threading.Thread): |
| 1780 | def __init__(self, pool): |
| 1781 | super().__init__() |
| 1782 | self.running = True |
| 1783 | self.pool = pool |
| 1784 | |
| 1785 | def stop(self): |
| 1786 | self.running = False |
| 1787 | |
| 1788 | def _run(self): |
| 1789 | while self.running: |
| 1790 | exc = AutoReconnect("mock pool error") |
| 1791 | ctx = _ErrorContext(exc, 0, pool.gen.get_overall(), False, None) |
| 1792 | client._topology.handle_error(pool.address, ctx) |
| 1793 | time.sleep(0.001) |
| 1794 | |
| 1795 | def run(self): |
| 1796 | self._run() |
| 1797 | |
| 1798 | t = ResetPoolThread(pool) |
| 1799 | t.start() |
| 1800 | |
| 1801 | # Ensure that update_pool completes without error even when the pool |
| 1802 | # is reset concurrently. |
| 1803 | try: |
| 1804 | while True: |
| 1805 | for _ in range(10): |
| 1806 | client._topology.update_pool() |
| 1807 | if generation != pool.gen.get_overall(): |
| 1808 | break |
| 1809 | finally: |
| 1810 | t.stop() |
| 1811 | t.join() |
| 1812 | client.admin.command("ping") |
| 1813 | |
| 1814 | def test_background_connections_do_not_hold_locks(self): |
| 1815 | min_pool_size = 10 |
nothing calls this directly
no test coverage detected