# Lgpio.error: 'GPIO busy' from test scripts

**URL:** <https://forum.sunfounder.com/t/lgpio-error-gpio-busy-from-test-scripts/4209>\
**Category:** Robotic kit for Raspberry Pi\
**Created:** [January 5, 2026, 11:12am UTC](https://forum.sunfounder.com/t/lgpio-error-gpio-busy-from-test-scripts/4209 "2026-01-05T11:12:24Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Spf650](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@Spf650](https://forum.sunfounder.com/u/Spf650)\
**Post date:** [January 5, 2026, 11:34am UTC](https://forum.sunfounder.com/t/lgpio-error-gpio-busy-from-test-scripts/4209/2 "2026-01-05T11:34:15Z")

</div>

That’s the normal behaviour, albeit probably unexpected!

You’re running into a hard boundary between OS-managed resources and external hardware state. A ctrl-c, such as early program termination or interrupting an Infinite loop frees the mcu resources from the linux core, whereas other exit methods do not.

As far as I could ever determine, dog.close() is not a cleanup method, it is a terminal control-flow primitive, it assumes it is called from top-level code and it was never meant to return.

So, in summary, what you see is normal. The other examples that run infinitely, will need ctrl-c to terminate anyway and this then automatically frees resources. They are absolutely fine.

I tried to explain the options a bit better here via 3 different worked example scenarios

> [@GPIO state after a program abort or user exit](https://forum.sunfounder.com/t/gpio-state-after-a-program-abort-or-user-exit/4181):
>
> I hope this little topic is of some help I’ve seen several user questions whereby when a program terminates incorrectly for whatever reason, it can leave the GPIO in a “busy” state. Usually requiring a reboot. Instead of a reboot one can often find the owner process id and just kill it e.g running some python code such as DummySpeech.py may show … File “/usr/lib/python3/dist-packages/lgpio.py”, line 458, in \_u2i raise error(error\_text(v)) lgpio.error: ‘GPIO busy’ on subsequent runs. To …

### Please note the above is my own interpretation and probably over simplified version of the process via a bit of reverse engineering, not confirmed in any way by Sunfounder, please feel free to ignore! I could be totally wrong.

---

_[View the full topic](https://forum.sunfounder.com/t/lgpio-error-gpio-busy-from-test-scripts/4209)._
