(self, timeout: int = 2)
| 58 | return False |
| 59 | |
| 60 | def cleanup(self, timeout: int = 2): |
| 61 | self._shutting_down = True |
| 62 | self.is_initialized = False |
| 63 | self.task_pg = None |
| 64 | |
| 65 | if not dist.is_initialized(): |
| 66 | return |
| 67 | |
| 68 | import threading |
| 69 | |
| 70 | def _destroy(): |
| 71 | try: |
| 72 | dist.destroy_process_group() |
| 73 | except Exception: |
| 74 | pass |
| 75 | |
| 76 | t = threading.Thread(target=_destroy, daemon=True) |
| 77 | t.start() |
| 78 | t.join(timeout=timeout) |
| 79 | |
| 80 | if t.is_alive(): |
| 81 | logger.warning(f"Rank {self.rank} cleanup timed out, forcing exit") |
| 82 | else: |
| 83 | logger.info(f"Rank {self.rank} distributed environment cleaned up") |
| 84 | |
| 85 | def barrier(self): |
| 86 | if self.is_initialized and dist.is_initialized(): |
nothing calls this directly
no test coverage detected