circuit.py
Check the test file next to the source for real usage.
This is a basic state machine for closed, open, and half-open states. I injected the clock so you can test timeouts without adding sleep calls. Zero external dependencies.
It relies strictly on the Python standard library. You do not need to install any third-party packages or manage external services. Just drop the file in your project and get back to shipping features.