From 042761f7659769704a3613cbc0580c244b0d7432 Mon Sep 17 00:00:00 2001
From: "William (Bill) E. Allcock" <allcock@anl.gov>
Date: Tue, 18 Jan 2022 23:33:05 +0000
Subject: [PATCH] added timeout to run and added the missing 'as ex'

---
 hook_job_info_syslog.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/hook_job_info_syslog.py b/hook_job_info_syslog.py
index 8c3d3db..4017c64 100644
--- a/hook_job_info_syslog.py
+++ b/hook_job_info_syslog.py
@@ -1,4 +1,7 @@
-
+# 
+# Add job start (EXECJOB_PROLOGUE) and job end (EXECJOB_EPILOGUE) events
+# to syslog to avoid having to go to the PBS accounting logs.
+#
 import pbs
 import subprocess
 
@@ -16,7 +19,7 @@ try:
 
     message = f'"PBS_MOM_Hook:{op}:Job:{jobid}"'
     tool = "/usr/bin/logger"
-    subprocess.run([tool, message], shell = False)
+    subprocess.run([tool, message], timeout = 10, shell = False)
     e.accept()
-except Exception:
-   e.reject(f"hook_job_info_syslog.py threw exception: {e}")  
+except Exception as ex:
+   e.reject(f"hook_job_info_syslog.py threw exception: {ex}")  
-- 
GitLab