This is under python 2.6 on CentOS6.
I am getting quite a bit of [gpg] from python's gnupg.GPG() module in a multi-threaded situation. The world seems to be fine when there is only 1 thread, but having more would start showing [gpg] under each python thread from ps -aefx.
Tried a few thing in adding a lock, but I don't believe that help either. Would that because GPG module is a wrapper calling subprocess, and subproces generally is not threadsafe?
GPG_LOCK = threading.LOCK()
def decrypt(s):
LOG.debug("decrpting: {0}".format(s))
d = None
try:
GPG_LOCK.acquire()
gpg = gnupg.GPG(binary='/usr/bin/gpg',homedir='/gpgkeys',verbose='advanced')
d = gpg.decrypt(s)
LOG.debug("decrypted string: {0}".format(d.data))
LOG.debug("decrupted error: {0}".format(d.stderr))
except Exception as e:
LOG.error(e)
traceback.print_exc()
finally:
GPG_LOCK.release()
return d.data if d else None