Adaptive waiting and execution engine — replaces time.sleep() with system-aware, deterministic waiting.
Project description
🚀 NanoWait — Adaptive Execution Engine for Python
NanoWait is not a sleep function. It’s an adaptive execution engine.
Execute. Retry. Adapt. Learn.
📦 Installation
pip install nano-wait
⚡ Quick Start
1. Smart Wait (better than sleep)
from nano_wait import wait
wait(2) # adapts to your CPU, memory and Wi-Fi
2. Wait until something happens
wait(lambda: button_is_visible(), timeout=10)
3. Execution Engine (🔥 core feature)
from nano_wait import execute
result = execute(lambda: fetch_data())
print(result.success)
4. Retry (clean and powerful)
from nano_wait import retry
@retry(timeout=5)
def click_button():
return driver.click("#submit")
5. 🤖 Agent (NEW — experimental)
from nano_wait import Agent
agent = Agent(verbose=True)
agent.run("click login")
High-level automation layer (future AI-ready interface)
🧠 Core Concepts
1. Adaptive Wait
NanoWait dynamically adjusts timing based on:
- CPU usage
- Memory pressure
- Wi-Fi signal
- Execution profile
- Historical learning
2. Execution Engine
NanoWait doesn’t just wait — it executes with intelligence:
execute(
fn,
timeout=10,
interval=0.2
)
3. Scheduler
Internally:
schedule(interval)
→ replaces time.sleep() with adaptive timing.
4. Agent Layer (NEW)
agent.run("click login button")
NanoWait is evolving into:
🧠 a system that observes → decides → acts
🔁 API Reference
wait()
wait(
t: float | Callable | None,
timeout: float = 15.0,
wifi: str | None = None,
speed: str | float = "normal",
smart: bool = False,
verbose: bool = False,
log: bool = False,
explain: bool = False,
telemetry: bool = False,
profile: str | None = None
)
Modes
⏱ Time Mode
wait(2)
🔄 Condition Mode
wait(lambda: is_ready(), timeout=10)
execute() ⭐
execute(
fn,
timeout=10,
interval=0.2,
profile=None,
verbose=False
)
Example
def fetch():
return api.get_data()
result = execute(fetch, timeout=5)
Return
ExecutionResult(
success=True,
result=...,
attempts=3,
duration=1.23
)
retry
@retry(timeout=5, interval=0.2)
def connect():
return connect_to_server()
Agent (experimental)
agent = Agent()
agent.run("wait")
agent.run("click submit")
⚙️ Execution Profiles
profile="ci" # fast & aggressive
profile="testing" # balanced
profile="rpa" # stable & safe
🧠 Smart Mode
wait(2, smart=True)
Automatically adapts to:
- slow machines → longer waits
- fast machines → shorter waits
📊 Telemetry
wait(2, telemetry=True)
Displays:
- adaptive factor
- intervals
- real-time adjustments
🧪 Explain Mode
report = wait(2, explain=True)
print(report)
Returns:
- final wait time
- adaptive factor
- CPU/Wi-Fi scores
- internal decisions
🤖 CLI
Basic
nano-wait 2
Async
nano-wait 2 --async
Pool
nano-wait --pool 1 2 3
Auto
nano-wait --auto
⚙️ Execution
nano-wait --exec "lambda: 1+1"
🤖 Agent (NEW)
nano-wait --agent "click login"
🧩 Real Use Cases
Selenium / Playwright
execute(
lambda: driver.find_element("#btn").click(),
timeout=5
)
API Retry
execute(
lambda: requests.get(url),
timeout=5
)
RPA
@retry(timeout=10)
def open_app():
click_icon()
🧠 Learning Engine
NanoWait learns from execution:
- delays
- failures
- timeouts
Improving future runs automatically.
Stored at:
~/.nano_wait_learning.json
🔥 Why NanoWait?
Most systems separate:
time.sleep()❌- retry ❌
- polling ❌
NanoWait unifies everything:
✅ Adaptive Scheduler ✅ Execution Engine ✅ Learning System ✅ Telemetry ✅ Agent Layer (new)
🚀 Roadmap
- AI-powered Agent (LLM integration)
- Vision integration (
nano-wait-vision) - execute_async
- circuit breaker
- error classification
💡 Philosophy
“Don’t wait blindly. Execute intelligently.”
⚡ Final insight (isso aqui é o diferencial real)
NanoWait is evolving from:
a timing utility
to:
🧠 an adaptive execution system for real-world automation
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 nano_wait-5.2.0.tar.gz.
File metadata
- Download URL: nano_wait-5.2.0.tar.gz
- Upload date:
- Size: 18.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7737b05f3d86c4694f2db9ca3963abd04a8173cf0587f7d274ab60de240c9733
|
|
| MD5 |
6ff7fbbbfe7dc729dcf64d572b1a24a1
|
|
| BLAKE2b-256 |
efa8ad7b688b06231b0f5bc9c1cefb2422369fb88e0fd6b9a10aed2a26a4cb1f
|
File details
Details for the file nano_wait-5.2.0-py3-none-any.whl.
File metadata
- Download URL: nano_wait-5.2.0-py3-none-any.whl
- Upload date:
- Size: 20.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ac277ffc51cbe38c52fc5526805c577484dff57f94af0811336379d01b6b692
|
|
| MD5 |
d2df3a4fb22e584a99213e7bc707ad67
|
|
| BLAKE2b-256 |
332b58f68ed0766e06a4e44ebe229df6277e3a3bd6e6ca7c12204fcb6123c0e5
|