spyoungtech / ahk

Python wrapper for AutoHotkey with full type support. Harness the automation power of AutoHotkey with the beauty of Python.
MIT License
887 stars 66 forks source link

GH-338 allow garbage collection of non-daemon processes #339

Closed spyoungtech closed 2 months ago

spyoungtech commented 2 months ago

As described in #338 use of atexit.register in AsyncAHKProcess causes a reference to be held for the subprocess. In use cases that make heavy use of run_script or calls with blocking=False, this can lead to buildup of memory. The rate of growth can be dependent on the size of the value returned by the script and how often it is called.

This PR fixes this issue by avoiding the need for atexit.register for these two scenarios. atexit.register is still used for the long-running daemon process to ensure cleanup.

coveralls commented 2 months ago

Coverage Status

coverage: 76.87% (+0.2%) from 76.659% when pulling 62e5940945fb04e00ea160d14f8aef447cbb8f9b on gh-338 into 46bce5c3e19aaa9fe49f1a90816a80a96a39a2c2 on main.

spyoungtech commented 2 months ago

This might also resolve #332