[PR #48] [MERGED] feat(core/collector): add function and method to collect metrics in background thread #134

Closed
opened 2026-05-05 03:26:29 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/XuehaiPan/nvitop/pull/48
Author: @XuehaiPan
Created: 11/17/2022
Status: Merged
Merged: 11/18/2022
Merged by: @XuehaiPan

Base: mainHead: collector-daemon


📝 Commits (6)

  • 244f3ba feat(core/collector): add function to collect metrics in background thread
  • 41bcf5c fix(core/collector): fix Python 3.5 syntax
  • b443be4 feat(core/collector): add daemonize method shortcut
  • 36f5d72 docs(core/collector): update docstrings
  • 0ca9a7f docs(core/collector): update README
  • 3173eef docs(core/collector): update docs

📊 Changes

4 files changed (+208 additions, -3 deletions)

View changed files

📝 README.md (+37 -0)
📝 docs/source/core/collector.rst (+4 -0)
📝 nvitop/core/__init__.py (+2 -1)
📝 nvitop/core/collector.py (+165 -2)

📄 Description

Issue Type

  • Improvement/feature implementation

Runtime Environment

  • Operating system and version: Ubuntu 20.04 LTS
  • Terminal emulator and version: GNOME Terminal 3.36.2
  • Python version: 3.9.13
  • NVML version (driver version): 470.129.06
  • nvitop version or commit: v0.10.1
  • python-ml-py version: 11.515.75
  • Locale: en_US.UTF-8

Description

Add a function to create a background daemon for metrics collectors.

A minimal example:

from nvitop import collect_in_background

def on_collect(metrics):
    print(metrics)
    return True

collect_in_background(on_collect)  # print metrics to stdout every 1 second

Motivation and Context

Resolves #47


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/XuehaiPan/nvitop/pull/48 **Author:** [@XuehaiPan](https://github.com/XuehaiPan) **Created:** 11/17/2022 **Status:** ✅ Merged **Merged:** 11/18/2022 **Merged by:** [@XuehaiPan](https://github.com/XuehaiPan) **Base:** `main` ← **Head:** `collector-daemon` --- ### 📝 Commits (6) - [`244f3ba`](https://github.com/XuehaiPan/nvitop/commit/244f3babe4218dafe277f82e8cef3cc0d0352ce7) feat(core/collector): add function to collect metrics in background thread - [`41bcf5c`](https://github.com/XuehaiPan/nvitop/commit/41bcf5c42c7649e745d2c712dfd878d3eed32ee9) fix(core/collector): fix Python 3.5 syntax - [`b443be4`](https://github.com/XuehaiPan/nvitop/commit/b443be4ecfc685a9cdaff2134f58fc4b24b87a75) feat(core/collector): add `daemonize` method shortcut - [`36f5d72`](https://github.com/XuehaiPan/nvitop/commit/36f5d723c9c14be406b4d2f7658a2ec91f31b0d0) docs(core/collector): update docstrings - [`0ca9a7f`](https://github.com/XuehaiPan/nvitop/commit/0ca9a7f9a0d5452433ad9ce5fb044831872483dd) docs(core/collector): update README - [`3173eef`](https://github.com/XuehaiPan/nvitop/commit/3173eef408dd2ed3368933175a44ee244f2ed594) docs(core/collector): update docs ### 📊 Changes **4 files changed** (+208 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+37 -0) 📝 `docs/source/core/collector.rst` (+4 -0) 📝 `nvitop/core/__init__.py` (+2 -1) 📝 `nvitop/core/collector.py` (+165 -2) </details> ### 📄 Description <!-- Provide a descriptive summary of the changes in the title above --> #### Issue Type <!-- Pick relevant types and delete the rest --> - Improvement/feature implementation #### Runtime Environment <!-- Details of your runtime environment --> - Operating system and version: Ubuntu 20.04 LTS - Terminal emulator and version: GNOME Terminal 3.36.2 - Python version: `3.9.13` - NVML version (driver version): `470.129.06` - `nvitop` version or commit: `v0.10.1` - `python-ml-py` version: `11.515.75` - Locale: `en_US.UTF-8` #### Description <!-- Describe the changes in detail --> Add a function to create a background daemon for metrics collectors. A minimal example: ```python from nvitop import collect_in_background def on_collect(metrics): print(metrics) return True collect_in_background(on_collect) # print metrics to stdout every 1 second ``` #### Motivation and Context <!-- Why are these changes required? --> <!-- What problems do these changes solve? --> <!-- Link to relevant issues --> Resolves #47 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror 2026-05-05 03:26:29 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/nvitop#134
No description provided.