|
1 | 1 | # CHANGELOG |
| 2 | +## Version 0.61.1 (March 2026) |
| 3 | + |
| 4 | +**Released**: March 15, 2026 |
| 5 | + |
| 6 | +This release improves async support with a new `arun()` helper and makes the Device Utilities module fully non-blocking. |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +### 1. NEW FEATURES |
| 11 | + |
| 12 | +#### **`mistapi.arun()` - Async Helper** |
| 13 | +New helper function to run any sync mistapi function without blocking the event loop. Wraps the function call in `asyncio.to_thread()` so blocking HTTP requests run in a thread pool. |
| 14 | + |
| 15 | +```python |
| 16 | +import asyncio |
| 17 | +import mistapi |
| 18 | +from mistapi.api.v1.sites import devices |
| 19 | + |
| 20 | +async def main(): |
| 21 | + session = mistapi.APISession(env_file="~/.mist_env") |
| 22 | + session.login() |
| 23 | + |
| 24 | + # Run sync API call without blocking the event loop |
| 25 | + response = await mistapi.arun(devices.listSiteDevices, session, site_id) |
| 26 | + print(response.data) |
| 27 | + |
| 28 | +asyncio.run(main()) |
| 29 | +``` |
| 30 | + |
| 31 | +--- |
| 32 | + |
| 33 | +### 2. IMPROVEMENTS |
| 34 | + |
| 35 | +#### **Non-Blocking Device Utilities** |
| 36 | +All `mistapi.device_utils` functions now return immediately. The HTTP trigger and WebSocket streaming run in background threads, allowing your code to continue executing while data is collected. |
| 37 | + |
| 38 | +**UtilResponse Object:** |
| 39 | +| Method/Property | Description | |
| 40 | +|-----------------|-------------| |
| 41 | +| `.ws_data` | List of processed messages | |
| 42 | +| `.done` | `True` if data collection is complete | |
| 43 | +| `.wait(timeout)` | Block until complete, returns self | |
| 44 | +| `.receive()` | Generator yielding messages as they arrive | |
| 45 | +| `.disconnect()` | Stop the WebSocket connection early | |
| 46 | +| `await response` | Async-friendly wait (non-blocking event loop) | |
| 47 | + |
| 48 | +**Example Usage:** |
| 49 | +```python |
| 50 | +from mistapi.device_utils import ex |
| 51 | + |
| 52 | +# Non-blocking - returns immediately, data collected in background |
| 53 | +response = ex.ping(apisession, site_id, device_id, host="8.8.8.8") |
| 54 | +do_other_work() # Can do other things while waiting |
| 55 | +response.wait() # Block when ready to collect results |
| 56 | +print(response.ws_data) |
| 57 | + |
| 58 | +# Generator style - process messages as they arrive |
| 59 | +for msg in response.receive(): |
| 60 | + print(msg) |
| 61 | + |
| 62 | +# Async-friendly - doesn't block the event loop |
| 63 | +await response |
| 64 | +``` |
| 65 | + |
| 66 | +--- |
| 67 | + |
2 | 68 | ## Version 0.61.0 (March 2026) |
3 | 69 |
|
4 | 70 | **Released**: March 13, 2026 |
|
0 commit comments