(self)
| 281 | self.wake_loop() |
| 282 | |
| 283 | def _cleanup(self): |
| 284 | global _dispatcher_map |
| 285 | |
| 286 | self._shutdown = True |
| 287 | if not self._thread: |
| 288 | return |
| 289 | |
| 290 | log.debug("Waiting for event loop thread to join...") |
| 291 | self._thread.join(timeout=1.0) |
| 292 | if self._thread.is_alive(): |
| 293 | log.warning( |
| 294 | "Event loop thread could not be joined, so shutdown may not be clean. " |
| 295 | "Please call Cluster.shutdown() to avoid this.") |
| 296 | |
| 297 | log.debug("Event loop thread was joined") |
| 298 | |
| 299 | # Ensure all connections are closed and in-flight requests cancelled |
| 300 | for conn in tuple(_dispatcher_map.values()): |
| 301 | if conn is not self._loop_dispatcher: |
| 302 | conn.close() |
| 303 | self._timers.service_timeouts() |
| 304 | # Once all the connections are closed, close the dispatcher |
| 305 | self._loop_dispatcher.close() |
| 306 | |
| 307 | log.debug("Dispatchers were closed") |
| 308 | |
| 309 | |
| 310 | _global_loop = None |
no test coverage detected