Pre-release
This release is a pre-release and may not be stable for production use.
HEXFELLOW RUNTIME UTILITIES
📖 Overview
What is hex_util_runtime
hex_util_runtime is a lightweight Python utility library providing essential runtime primitives with minimal dependencies. It is part of the HEXFELLOW ecosystem and serves as the foundational layer for time management, inter-process communication, environment configuration, and file system operations.
| Module | Primary Purpose | Key Components |
|---|---|---|
| time_utils | High-precision time, PTP clock, loop rate control | ns_now(), HexRate, HexTimeManager |
| buffer_utils | Thread-safe variable + lock-free SPSC shared-memory ring buffer | HexThreadingVar, HexShmRingBuffer, deque_helper |
| env_util | Type-safe environment variable readers | get_env_int(), get_env_bool(), get_env_ndarray() |
| file_utils | Safe recursive directory removal | hex_rmtree() |
What problem it solves
- Unified time interface: Abstract away the difference between system monotonic clocks and PTP hardware clocks behind a simple
ns_now()call. - Thread-safe variable exchange: Wrap any Python value with
HexThreadingVarto safely read/write across threads using a mutex lock. - High-frequency inter-process streaming: Provide a lock-free, single-producer-single-consumer shared-memory ring buffer (
HexShmRingBuffer) optimized for 2–5 kHz+ data rates, avoiding serialization and IPC overhead. - Safe environment configuration: Read environment variables with proper type conversion and fallback defaults, without repetitive
try/exceptboilerplate. - Portable file operations: Pure-
osimplementation of recursive directory deletion, removing theshutildependency.
Target users
- Robotics engineers who need low-latency, lock-free shared-memory communication between processes.
- Developers building real-time control loops with precise timing requirements.
- Anyone working in the HEXFELLOW ecosystem (
hex_driver_mujoco,hex_util_robot, etc.) who needs runtime primitives.
Project structure
hex_util_runtime/
├── hex_util_runtime/
│ ├── __init__.py # Public exports (__all__)
│ ├── time_utils.py # ns_now(), HexRate, HexTimeManager, hex timestamp converters
│ ├── buffer_utils.py # HexThreadingVar (thread-safe variable), HexShmRingBuffer (lock-free SPSC SHM ring buffer), deque_helper
│ ├── env_util.py # get_env_str/get_env_int/get_env_bool/get_env_float/get_env_ndarray
│ └── file_utils.py # hex_rmtree (safe recursive directory removal)
├── docs/
│ ├── api.md # Full API reference
│ └── example.md # Usage walkthroughs
└── pyproject.toml # Project metadata & build configuration
📦 Installation
Requirements
- Python ≥ 3.8
- OS: Linux (POSIX shared memory and PTP clock support are Linux-specific)
- Dependencies:
numpy ≥ 2.2.6
Install from PyPI
pip install hex_util_runtime
Install from Source
We use uv to manage the Python environment. Please install it first.
- Clone and install in editable mode:
git clone https://github.com/hexfellow/hex_util_runtime.git
cd hex_util_runtime
./venv.sh
- Activate before using:
source .venv/bin/activate
⚡ Quick Start
from hex_util_runtime import ns_now, HexRate, hex_ts_now
from hex_util_runtime import get_env_int, hex_rmtree
from hex_util_runtime import HexThreadingVar, HexShmRingBuffer, deque_helper
# Get current time in nanoseconds
print(ns_now())
# Rate-limited loop (100 Hz)
rate = HexRate(100)
for _ in range(10):
rate.sleep()
print(f"ts: {hex_ts_now()}")
# Read an integer from environment (default 0)
interval = get_env_int("MY_INTERVAL_MS", default=50)
📑 Documentation
- API Reference — Detailed documentation of all classes and functions.
- Examples — Usage walkthroughs for each module.
📄 License
Apache License 2.0. See LICENSE.
👥 Authors & Maintainers
| Role | Name | |
|---|---|---|
| Author | Dong Zhaorui | joray.dong@hexfellow.com |
| Maintainer | jecjune (Chen Zejun) | zejun.chen@hexfellow.com |
| Maintainer | Dong Zhaorui | joray.dong@hexfellow.com |
🌟 Star History
👥 Contributors
Metadata
Release files for hex-util-runtime 0.0.1a15
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hex_util_runtime-0.0.1a15.tar.gz | 11.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hex_util_runtime-0.0.1a15-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.0 kB
Release files / hex_util_runtime-0.0.1a15.tar.gz
| Download URL | hex_util_runtime-0.0.1a15.tar.gz |
|---|---|
| Size | 11.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8a162f7e3edb81f62dd79ed5c73b1a21c8201e26e26c7cbc3f3a97907bfd7c3c
|
|
BLAKE2b-256 checksum How to use checksums |
10e1d0f0201d3bf83cefd6f352dde00543ba4456800165d1ff2cf496a74c8b91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Release files / hex_util_runtime-0.0.1a15-py3-none-any.whl
| Download URL | hex_util_runtime-0.0.1a15-py3-none-any.whl |
|---|---|
| Size | 12.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fdf39e369b818063e0da93dc12a573666ec2cc1297776127446f5f80990fb7cf
|
|
BLAKE2b-256 checksum How to use checksums |
6aaf72406021718825fdea40715bb9041755c7a2d9b21aa7875392b0055c18b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|