Browse Source

log memory usage in encrypt_file()

Son NK 5 years ago
parent
commit
123f3583fd
1 changed files with 5 additions and 0 deletions
  1. 5 0
      app/pgp_utils.py

+ 5 - 0
app/pgp_utils.py

@@ -1,6 +1,7 @@
 from io import BytesIO
 from io import BytesIO
 
 
 import gnupg
 import gnupg
+from memory_profiler import memory_usage
 
 
 from app.config import GNUPGHOME
 from app.config import GNUPGHOME
 from app.log import LOG
 from app.log import LOG
@@ -24,6 +25,10 @@ def load_public_key(public_key: str) -> str:
 
 
 
 
 def encrypt_file(data: BytesIO, fingerprint: str) -> str:
 def encrypt_file(data: BytesIO, fingerprint: str) -> str:
+    LOG.d("encrypt for %s", fingerprint)
+    mem_usage = memory_usage(-1, interval=1, timeout=1)
+    LOG.d("mem_usage %s", mem_usage)
+
     r = gpg.encrypt_file(data, fingerprint, always_trust=True)
     r = gpg.encrypt_file(data, fingerprint, always_trust=True)
     if not r.ok:
     if not r.ok:
         LOG.error("Try encrypt again %s", fingerprint)
         LOG.error("Try encrypt again %s", fingerprint)