Skip to content

Instantly share code, notes, and snippets.

@phiat
Created January 17, 2026 18:38
Show Gist options
  • Select an option

  • Save phiat/25a042a9beeec42161e0ed01ac18602b to your computer and use it in GitHub Desktop.

Select an option

Save phiat/25a042a9beeec42161e0ed01ac18602b to your computer and use it in GitHub Desktop.
Demo: sprites.dev sprite stays 'running' instead of going 'warm' after idle (Python)
#!/usr/bin/env python3
"""sprites_sleep_bug.py - Demonstrates sprite not going warm after idle"""
import os
import time
import requests
API = "https://api.sprites.dev/v1/sprites"
TOKEN = os.environ.get("SPRITES_TOKEN")
if not TOKEN:
raise SystemExit("Set SPRITES_TOKEN env var")
HEADERS = {
"Authorization": f"Bearer {TOKEN}",
"Content-Type": "application/json",
}
sprite_name = f"sleep-test-{int(time.time())}"
def get_status():
r = requests.get(f"{API}/{sprite_name}", headers=HEADERS)
return r.json().get("status", "unknown")
print(f"=== Creating sprite: {sprite_name} ===")
r = requests.post(API, headers=HEADERS, json={"name": sprite_name})
print(f"Initial status: {r.json().get('status')}")
print("\n=== Touching sprite (quick exec) ===")
try:
requests.post(
f"{API}/{sprite_name}/exec",
headers=HEADERS,
json={"command": ["true"]},
timeout=5,
)
except requests.exceptions.Timeout:
pass
print("Touched")
print("\n=== Monitoring status ===")
checkpoints = [(45, 45), (60, 15), (120, 60)] # (label, sleep_duration)
for label, wait in checkpoints:
print(f"Waiting {wait}s...")
time.sleep(wait)
status = get_status()
print(f"[{label}s] status: {status}")
if status == "warm":
print("SUCCESS: sprite went warm")
break
if status != "warm":
print(f"BUG: sprite still '{status}' after 120s idle")
print("\n=== Cleanup ===")
requests.delete(f"{API}/{sprite_name}", headers=HEADERS)
print(f"Deleted {sprite_name}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment