Lightweight background task monitor with live progress, ETA, hooks, concurrent tasks, and SQLite history
Project description
taskpulse
Lightweight background task monitor — live progress bars, ETA, elapsed time, concurrent tasks, callback hooks, and SQLite history. No Celery, no Redis, pure Python.
Installation
pip install taskpulse
No dependencies. Requires Python 3.8+.
Quick Start
from taskpulse import TaskPulse
pulse = TaskPulse()
@pulse.task(name="Process files", total=100)
def process(task):
for i in range(100):
do_work()
task.update(i + 1)
return "done"
t = pulse.run(process)
pulse.wait(t.id)
print(t.result) # "done"
Terminal output:
⚡ Process files [████████████░░░░░░░░░░░░░░░░░░] 41.0% elapsed 2.1s ETA 3.0s
✅ Process files [done] elapsed 5.1s
Usage
Define Tasks
# Decorator style
@pulse.task(name="My Task", total=50)
def my_task(task):
for i in range(50):
process_item(i)
task.update(i + 1) # report progress
return "finished"
# Run it
t = pulse.run(my_task)
# Inline (no decorator)
def simple(task, items):
for i, item in enumerate(items):
process(item)
task.update(i + 1, total=len(items))
return len(items)
t = pulse.run(simple, my_items, name="Process items")
Progress Updates
def fn(task):
task.update(5) # just update progress
task.update(10, total=50) # also update total
Concurrent Tasks
tasks = [pulse.run(process, batch) for batch in batches]
pulse.wait(*[t.id for t in tasks]) # wait for all
Hooks
def on_start(task):
print(f"Starting: {task.name}")
def on_progress(task):
if task.percent and task.percent > 50:
notify_team("halfway done")
def on_done(task):
send_email(f"Task complete: {task.result}")
def on_error(task):
alert(f"Task failed: {task.error}")
@pulse.task(
name="Important Job",
on_start=on_start,
on_progress=on_progress,
on_done=on_done,
on_error=on_error,
)
def important_job(task):
...
Task Status
task = pulse.get("task-0001")
print(task.status) # TaskStatus.RUNNING
print(task.percent) # 42.0
print(task.elapsed) # 3.2 (seconds)
print(task.eta) # 4.4 (seconds remaining)
print(task.result) # None while running
print(task.error) # None if no error
Live Dashboard
from taskpulse import TaskPulse
from taskpulse import Monitor
pulse = TaskPulse(show_progress=False)
monitor = Monitor(pulse, refresh=0.5)
monitor.start()
for batch in batches:
pulse.run(process, batch)
pulse.wait()
monitor.stop()
SQLite History
# Full run history persisted across restarts
history = pulse.history(limit=20)
for run in history:
print(run["name"], run["status"], run["elapsed"])
API Reference
TaskPulse
TaskPulse(
db_path="taskpulse.db", # SQLite history file
max_workers=4, # Max concurrent tasks
show_progress=True, # Live progress bars
)
| Method | Description |
|---|---|
task(name, total, on_start, ...) |
Decorator to define a task |
run(func, *args, **kwargs) |
Submit task, returns Task immediately |
wait(*task_ids, timeout) |
Block until tasks complete |
get(task_id) |
Get Task by ID |
all_tasks() |
List all Task objects |
status() |
List of status dicts |
history(limit) |
Run history from SQLite |
print_status() |
Print formatted table |
cancel(task_id) |
Cancel a pending task |
Task
| Attribute | Type | Description |
|---|---|---|
id |
str |
Unique task ID |
name |
str |
Task name |
status |
TaskStatus |
pending/running/done/failed/cancelled |
progress |
int |
Current step count |
total |
int | None |
Total steps |
percent |
float | None |
0-100 |
elapsed |
float |
Seconds since start |
eta |
float | None |
Estimated seconds remaining |
result |
Any |
Return value (when done) |
error |
str | None |
Traceback (when failed) |
Running Tests
pip install pytest
pytest tests/ -v
License
MIT © prabhay759
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file taskpulse-1.0.0.tar.gz.
File metadata
- Download URL: taskpulse-1.0.0.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f31dc0c0e9d25478209cb7d8b777fa53dc0fdd2ff72dd550576b9ba07641864a
|
|
| MD5 |
20b3c773be0d23cab9f812e180ce9616
|
|
| BLAKE2b-256 |
2b6fc24ea51939dcb4c04536ec25367dcc1f304815876c3506f313703efe6216
|
Provenance
The following attestation bundles were made for taskpulse-1.0.0.tar.gz:
Publisher:
Publish.yml on prabhay759/taskpulse
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
taskpulse-1.0.0.tar.gz -
Subject digest:
f31dc0c0e9d25478209cb7d8b777fa53dc0fdd2ff72dd550576b9ba07641864a - Sigstore transparency entry: 1224343549
- Sigstore integration time:
-
Permalink:
prabhay759/taskpulse@b4dc183f34426574ca9f278172b189cbc3a433e3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/prabhay759
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
Publish.yml@b4dc183f34426574ca9f278172b189cbc3a433e3 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file taskpulse-1.0.0-py3-none-any.whl.
File metadata
- Download URL: taskpulse-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
586e75453cc672f28293972868db492e75fe9168fd97d62e79f4058dd9a78713
|
|
| MD5 |
c1f06ea2df5ffffa8e2cc760f75eb691
|
|
| BLAKE2b-256 |
83d99786585cf1648959e9cea5c1d1f2bcf9750574fcad785525e024a697bf25
|
Provenance
The following attestation bundles were made for taskpulse-1.0.0-py3-none-any.whl:
Publisher:
Publish.yml on prabhay759/taskpulse
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
taskpulse-1.0.0-py3-none-any.whl -
Subject digest:
586e75453cc672f28293972868db492e75fe9168fd97d62e79f4058dd9a78713 - Sigstore transparency entry: 1224343550
- Sigstore integration time:
-
Permalink:
prabhay759/taskpulse@b4dc183f34426574ca9f278172b189cbc3a433e3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/prabhay759
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
Publish.yml@b4dc183f34426574ca9f278172b189cbc3a433e3 -
Trigger Event:
workflow_dispatch
-
Statement type: