Close all connections. ``Session`` instances should not be used for any purpose after being shutdown.
(self)
| 3239 | log.exception("Error preparing query for host %s:", host) |
| 3240 | |
| 3241 | def shutdown(self): |
| 3242 | """ |
| 3243 | Close all connections. ``Session`` instances should not be used |
| 3244 | for any purpose after being shutdown. |
| 3245 | """ |
| 3246 | with self._lock: |
| 3247 | if self.is_shutdown: |
| 3248 | return |
| 3249 | else: |
| 3250 | self.is_shutdown = True |
| 3251 | |
| 3252 | # PYTHON-673. If shutdown was called shortly after session init, avoid |
| 3253 | # a race by cancelling any initial connection attempts haven't started, |
| 3254 | # then blocking on any that have. |
| 3255 | for future in self._initial_connect_futures: |
| 3256 | future.cancel() |
| 3257 | wait_futures(self._initial_connect_futures) |
| 3258 | |
| 3259 | if self._monitor_reporter: |
| 3260 | self._monitor_reporter.stop() |
| 3261 | |
| 3262 | for pool in tuple(self._pools.values()): |
| 3263 | pool.shutdown() |
| 3264 | |
| 3265 | def __enter__(self): |
| 3266 | return self |