Return TensorBoardInfo values for running TensorBoard processes. This function may not provide a perfect snapshot of the set of running processes. Its result set may be incomplete if the user has cleaned their /tmp/ directory while TensorBoard processes are running. It may contain e
()
| 283 | |
| 284 | |
| 285 | def get_all(): |
| 286 | """Return TensorBoardInfo values for running TensorBoard processes. |
| 287 | |
| 288 | This function may not provide a perfect snapshot of the set of running |
| 289 | processes. Its result set may be incomplete if the user has cleaned |
| 290 | their /tmp/ directory while TensorBoard processes are running. It may |
| 291 | contain extraneous entries if TensorBoard processes exited uncleanly |
| 292 | (e.g., with SIGKILL or SIGQUIT). |
| 293 | |
| 294 | Entries in the info directory that do not represent valid |
| 295 | `TensorBoardInfo` values will be silently ignored. |
| 296 | |
| 297 | Returns: |
| 298 | A fresh list of `TensorBoardInfo` objects. |
| 299 | """ |
| 300 | info_dir = _get_info_dir() |
| 301 | results = [] |
| 302 | for filename in os.listdir(info_dir): |
| 303 | filepath = os.path.join(info_dir, filename) |
| 304 | try: |
| 305 | with open(filepath) as infile: |
| 306 | contents = infile.read() |
| 307 | except IOError as e: |
| 308 | if e.errno == errno.EACCES: |
| 309 | # May have been written by this module in a process whose |
| 310 | # `umask` includes some bits of 0o444. |
| 311 | continue |
| 312 | else: |
| 313 | raise |
| 314 | try: |
| 315 | info = _info_from_string(contents) |
| 316 | except ValueError: |
| 317 | # Ignore unrecognized files, logging at debug only. |
| 318 | tb_logging.get_logger().debug( |
| 319 | "invalid info file: %r", |
| 320 | filepath, |
| 321 | exc_info=True, |
| 322 | ) |
| 323 | else: |
| 324 | results.append(info) |
| 325 | return results |
| 326 | |
| 327 | |
| 328 | @dataclasses.dataclass(frozen=True) |
no test coverage detected
searching dependent graphs…