Adaptive waiting and execution engine — replaces time.sleep() with system-aware, deterministic waiting.
Project description
🚀 NanoWait — Execution Layer for Python
NanoWait is not a sleep function. It’s an adaptive execution engine.
Execute. Retry. Adapt. Learn.
📦 Instalação
pip install nano-wait
⚡ Quick Start
1. Smart Wait (clássico, mas melhor)
from nano_wait import wait
wait(2) # adaptativo baseado no seu PC/Wi-Fi
2. Esperar até algo acontecer
wait(lambda: button_is_visible(), timeout=10)
3. Execution Layer (🔥 principal)
from nano_wait import execute
result = execute(lambda: fetch_data())
print(result)
4. Retry automático
from nano_wait import retry
@retry(timeout=5)
def click_button():
return driver.click("#submit")
🧠 Core Concepts
1. Adaptive Wait
NanoWait ajusta automaticamente o tempo com base em:
- CPU usage
- Memory usage
- Wi-Fi signal
- Execution profile
- Histórico (learning)
2. Execution Engine
O NanoWait não só espera — ele executa com inteligência:
execute(
fn,
until=lambda result: result == "OK",
timeout=10,
interval=0.2
)
3. Scheduler
Internamente:
schedule(interval)
→ substitui time.sleep() com inteligência adaptativa.
🔁 API Reference
wait()
Assinatura
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
)
Modos
⏱ Time Mode
wait(2)
🔄 Condition Mode
wait(lambda: is_ready(), timeout=10)
execute() ⭐ (MAIN FEATURE)
execute(
fn: Callable,
until: Callable | None = None,
retry: bool = True,
timeout: float = 10.0,
interval: float = 0.1,
**kwargs
)
Exemplo real
def fetch():
return api.get_data()
result = execute(
fetch,
until=lambda r: r.status == 200,
timeout=5
)
Retorno
ExecutionResult(
success=True,
result=...,
attempts=3,
duration=1.23
)
retry decorator
@retry(timeout=5, interval=0.2)
def connect():
return connect_to_server()
⚙️ Perfis de Execução
profile="ci" # rápido e agressivo
profile="testing" # balanceado
profile="rpa" # mais estável
🧠 Smart Mode
wait(2, smart=True)
Ajusta automaticamente baseado no ambiente:
- PC lento → espera mais
- PC rápido → espera menos
📊 Telemetry (Debug visual)
wait(2, telemetry=True)
Mostra:
- Adaptive factor
- Intervalos
- Ajustes em tempo real
🧪 Explain Mode
report = wait(2, explain=True)
print(report)
Retorna:
- tempo final
- fator usado
- CPU/Wi-Fi score
- decisões internas
🤖 CLI
Wait normal
nano-wait 2
Async
nano-wait 2 --async
Pool
nano-wait --pool 1 2 3
Auto
nano-wait --auto
🔥 Execution via CLI
nano-wait --exec "lambda: 1+1"
🧩 Exemplos Reais
Selenium / Playwright
execute(
lambda: driver.find_element("#btn").click(),
retry=True,
timeout=5
)
API Retry
execute(
lambda: requests.get(url),
until=lambda r: r.status_code == 200
)
RPA
@retry(timeout=10)
def open_app():
click_icon()
🧠 Learning Engine
NanoWait aprende automaticamente:
- Se demorou mais que o esperado
- Se houve timeout
- Ajusta futuras execuções
Arquivo salvo em:
~/.nano_wait_learning.json
🔥 Diferencial
NanoWait combina:
time.sleep()❌- retry ❌
- polling ❌
em um único sistema:
✅ Adaptive Scheduler ✅ Execution Engine ✅ Self-learning ✅ Telemetry
🚀 Roadmap
-
execute_async - circuit breaker
- error classification
- integração com visão computacional (NanoWait Vision)
💡 Filosofia
“Don’t wait blindly. Execute intelligently.”
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.1.0.tar.gz.
File metadata
- Download URL: nano_wait-5.1.0.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f7040307e031aa5228fbf38a3db77378cbc11f210a2fcd93c2d0549f103598d
|
|
| MD5 |
98e4062cdf649e67b38ae397ea146be6
|
|
| BLAKE2b-256 |
4101f6a65c3160febeb30dc620324cec3e35b25f29a0b02a462aed24bda5d530
|
File details
Details for the file nano_wait-5.1.0-py3-none-any.whl.
File metadata
- Download URL: nano_wait-5.1.0-py3-none-any.whl
- Upload date:
- Size: 18.5 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 |
45169b9f6bf39d47034b16ec91fd950dbb44c56253cfe5680eef301f0d9a03cf
|
|
| MD5 |
271ad5da1a4edc0cdfe15c25cc7761d2
|
|
| BLAKE2b-256 |
55adf2876c4afa6ae8d181deac29e10264285e3151320fa683a0a6db652fd1b4
|