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.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hex_util_runtime-0.0.1.tar.gz | 11.5 kB | Without provenance | Details for hex_util_runtime-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hex_util_runtime-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for hex_util_runtime-0.0.1-py3-none-any.whl |
Total release size: 24.0 kB
Release files / hex_util_runtime-0.0.1.tar.gz
| Download URL | hex_util_runtime-0.0.1.tar.gz |
|---|---|
| Size | 11.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4b001b5ef210bd475c753c3ea7aedb47cfe815d8e0309adedf82626e6e80b5cd
|
|
BLAKE2b-256 checksum How to use checksums |
cd2659591ebe79878c1e9289b2154b3a31c0c8c0b4a204910829efb0c437f31f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.18
|
Release files / hex_util_runtime-0.0.1-py3-none-any.whl
| Download URL | hex_util_runtime-0.0.1-py3-none-any.whl |
|---|---|
| Size | 12.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a2628ffb986649eca33668417fbabd2202524383f1cc85e7a4eb96bf29c41809
|
|
BLAKE2b-256 checksum How to use checksums |
ede9e18fe98bce13794900552d731ef5bb6eb6148a6e1afbaae7b52954b76fe5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.18
|
Security for hex-util-runtime 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.