(args: Optional["Namespace"] = None, **kwargs)
| 169 | |
| 170 | @contextmanager |
| 171 | def debugtools(args: Optional["Namespace"] = None, **kwargs): |
| 172 | kw = vars(args) if args else {} |
| 173 | kw.update(kwargs) |
| 174 | |
| 175 | with ExitStack() as stack: |
| 176 | if kw.get("pdb"): |
| 177 | stack.enter_context(debug()) |
| 178 | if kw.get("cprofile") or kw.get("cprofile_dump"): |
| 179 | stack.enter_context(profile(kw.get("cprofile_dump"))) |
| 180 | if kw.get("instrument") or kw.get("instrument_open"): |
| 181 | stack.enter_context(instrument(kw.get("instrument_open", False))) |
| 182 | if kw.get("show_stack", False): |
| 183 | stack.enter_context(show_stack()) |
| 184 | if kw.get("yappi"): |
| 185 | path_func = _get_path_func("callgrind", "out") |
| 186 | stack.enter_context( |
| 187 | yappi_profile( |
| 188 | path=path_func, |
| 189 | separate_threads=kw.get("yappi_separate_threads"), |
| 190 | ) |
| 191 | ) |
| 192 | if ( |
| 193 | kw.get("viztracer") |
| 194 | or kw.get("viztracer_depth") |
| 195 | or kw.get("viztracer_async") |
| 196 | ): |
| 197 | path_func = _get_path_func("viztracer", "json") |
| 198 | depth = kw.get("viztracer_depth") or -1 |
| 199 | log_async = kw.get("viztracer_async") or False |
| 200 | prof = viztracer_profile(path=path_func, depth=depth, log_async=log_async) |
| 201 | stack.enter_context(prof) |
| 202 | yield |
| 203 | |
| 204 | |
| 205 | def add_debugging_flags(parser): |
no test coverage detected