Disconnects either all connections in the pool or just the free connections.
(self, inuse_connections: bool = True)
| 3688 | self._locked = False |
| 3689 | |
| 3690 | def disconnect(self, inuse_connections: bool = True): |
| 3691 | """ |
| 3692 | Disconnects either all connections in the pool or just the free connections. |
| 3693 | """ |
| 3694 | self._checkpid() |
| 3695 | try: |
| 3696 | if self._in_maintenance: |
| 3697 | self._lock.acquire() |
| 3698 | self._locked = True |
| 3699 | |
| 3700 | if inuse_connections: |
| 3701 | connections = self._connections |
| 3702 | else: |
| 3703 | connections = self._get_free_connections() |
| 3704 | |
| 3705 | for connection in connections: |
| 3706 | connection.disconnect() |
| 3707 | finally: |
| 3708 | if self._locked: |
| 3709 | try: |
| 3710 | self._lock.release() |
| 3711 | except Exception: |
| 3712 | pass |
| 3713 | self._locked = False |
| 3714 | |
| 3715 | def _get_free_connections(self): |
| 3716 | with self._lock: |