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.
coverage: 76.87% (+0.2%) from 76.659%
when pulling 62e5940945fb04e00ea160d14f8aef447cbb8f9b on gh-338
into 46bce5c3e19aaa9fe49f1a90816a80a96a39a2c2 on main.
As described in #338 use of
atexit.register
inAsyncAHKProcess
causes a reference to be held for the subprocess. In use cases that make heavy use ofrun_script
or calls withblocking=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.