You may be able to launch your python script from the runcommand-onstart script and reset it with the runcommand-onend script.
See: https://retropie.org.uk/docs/Runcommand/#runcommand-onstart-and-runcommand-onend-scripts
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.