()
| 154 | |
| 155 | |
| 156 | def print_alive_threads(): |
| 157 | assert enable_llm_debug( |
| 158 | ), "print_alive_threads must be called with enable_llm_debug() enabled" |
| 159 | |
| 160 | # Print all alive threads for debugging |
| 161 | alive_threads = [t for t in threading.enumerate() if t.is_alive()] |
| 162 | logger.info( |
| 163 | f'All alive threads after shutdown: {[t.name for t in alive_threads]}\n', |
| 164 | "red") |
| 165 | for t in alive_threads: |
| 166 | logger.info(f'Thread {t.name} (daemon={t.daemon}) is still alive') |
| 167 | # Get the stack trace for this thread |
| 168 | stack = sys._current_frames().get(t.ident) |
| 169 | if stack is not None: |
| 170 | logger.info(f'Stack trace for thread {t.name}:') |
| 171 | traceback.print_stack(stack, file=sys.stdout) |
| 172 | logger.info('') |
no test coverage detected