You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`mpos.audio.audioflinger`: Audio playback service - see [docs/frameworks/audioflinger.md](../docs/docs/frameworks/audioflinger.md)
582
586
-`mpos.lights`: LED control - see [docs/frameworks/lights-manager.md](../docs/docs/frameworks/lights-manager.md)
583
587
588
+
## Task Management (TaskManager)
589
+
590
+
MicroPythonOS provides a centralized async task management service called **TaskManager** for managing background operations.
591
+
592
+
**📖 User Documentation**: See [docs/frameworks/task-manager.md](../docs/docs/frameworks/task-manager.md) for complete API reference, patterns, and examples.
-**Thread model**: All tasks run on main asyncio event loop (cooperative multitasking)
600
+
601
+
### Quick Example
602
+
603
+
```python
604
+
from mpos import TaskManager, DownloadManager
605
+
606
+
classMyActivity(Activity):
607
+
defonCreate(self):
608
+
# Launch background task
609
+
TaskManager.create_task(self.download_data())
610
+
611
+
asyncdefdownload_data(self):
612
+
# Download with timeout
613
+
try:
614
+
data =await TaskManager.wait_for(
615
+
DownloadManager.download_url(url),
616
+
timeout=10
617
+
)
618
+
self.update_ui(data)
619
+
except asyncio.TimeoutError:
620
+
print("Download timed out")
621
+
```
622
+
623
+
### Critical Code Locations
624
+
625
+
- Task manager: `lib/mpos/task_manager.py`
626
+
- Used throughout OS for async operations (downloads, WebSockets, sensors)
627
+
628
+
## HTTP Downloads (DownloadManager)
629
+
630
+
MicroPythonOS provides a centralized HTTP download service called **DownloadManager** for async file downloads.
631
+
632
+
**📖 User Documentation**: See [docs/frameworks/download-manager.md](../docs/docs/frameworks/download-manager.md) for complete API reference, patterns, and examples.
633
+
634
+
### Implementation Details (for Claude Code)
635
+
636
+
-**Location**: `lib/mpos/net/download_manager.py`
637
+
-**Pattern**: Module-level singleton (similar to `audioflinger.py`, `battery_voltage.py`)
638
+
-**Session management**: Automatic lifecycle (lazy init, auto-cleanup when idle)
639
+
-**Thread-safe**: Uses `_thread.allocate_lock()` for session access
0 commit comments