Closes all sessions and connection associated with this Cluster. To ensure all connections are properly closed, **you should always call shutdown() on a Cluster instance when you are done with it**. Once shutdown, a Cluster should not be used for any purpose.
(self)
| 1750 | return holders |
| 1751 | |
| 1752 | def shutdown(self): |
| 1753 | """ |
| 1754 | Closes all sessions and connection associated with this Cluster. |
| 1755 | To ensure all connections are properly closed, **you should always |
| 1756 | call shutdown() on a Cluster instance when you are done with it**. |
| 1757 | |
| 1758 | Once shutdown, a Cluster should not be used for any purpose. |
| 1759 | """ |
| 1760 | with self._lock: |
| 1761 | if self.is_shutdown: |
| 1762 | return |
| 1763 | else: |
| 1764 | self.is_shutdown = True |
| 1765 | |
| 1766 | if self._idle_heartbeat: |
| 1767 | self._idle_heartbeat.stop() |
| 1768 | |
| 1769 | self.scheduler.shutdown() |
| 1770 | |
| 1771 | self.control_connection.shutdown() |
| 1772 | |
| 1773 | for session in tuple(self.sessions): |
| 1774 | session.shutdown() |
| 1775 | |
| 1776 | self.executor.shutdown() |
| 1777 | |
| 1778 | _discard_cluster_shutdown(self) |
| 1779 | |
| 1780 | def __enter__(self): |
| 1781 | return self |