From 1860026eca96395259b8e7b97ada31ca277aa93c Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk Date: May 17 2017 13:24:48 +0000 Subject: Use psutil's Process() instead of looping through all processes Signed-off-by: Patrick Uiterwijk --- diff --git a/pagure/mail_logging.py b/pagure/mail_logging.py index 4f99308..9fb62b6 100644 --- a/pagure/mail_logging.py +++ b/pagure/mail_logging.py @@ -128,17 +128,9 @@ class ContextInjector(logging.Filter): # pragma: no cover @staticmethod def get_current_process(): """ Return the current process (PID). """ - mypid = os.getpid() - if not psutil: return "Could not import psutil for %r" % mypid - - for proc in psutil.process_iter(): - if proc.pid == mypid: - return proc - - # This should be impossible. - raise ValueError("Could not find process %r" % mypid) + return psutil.Process() MSG_FORMAT = """Process Details