How to prevent passphrase-caching from within a gpgme-based Python script?
Digging in the C gpgme
library (which is what the Python library you use is wrapping), there is:
https://www.gnupg.org/documentation/manuals/gpgme/Context-Flags.html#Context-Flags
"no-symkey-cache"
For OpenPGP disable the passphrase cache used for symmetrical en- and decryption.
This cache is based on the message specific salt value. Requires at least GnuPG
2.2.7 to have an effect.
I'm not sure how the context is interacting with the filesystem or a GPG agent, but your first attempt should be setting this flag to true.