changeset 20:3abd271b4626 default tip

killing nist at exception
author pieter.lukasse@wur.nl
date Fri, 23 Jan 2015 17:57:00 +0100
parents a394029414c6
children
files nist_wrapper.py
diffstat 1 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/nist_wrapper.py	Fri Jan 23 17:42:19 2015 +0100
+++ b/nist_wrapper.py	Fri Jan 23 17:57:00 2015 +0100
@@ -142,6 +142,7 @@
         if timeSleeping > (startUpTime + job_size*2):
             # abort with timeout:
             utils.log_message(log_file, "No results after " + str(timeSleeping) + " seconds...")
+            _kill_NIST(pro, is_wine)
             # uggly workaround: 
             utils.kill_process_by_name("nistms.exe")
             utils.kill_process_by_name("nistms$.exe")
@@ -151,19 +152,29 @@
     # kill process:
     #p.terminate() - not needed, nistm$ will terminate...nistms.exe is the one that 
     #stays open...and orphan..killing it:
+    _kill_NIST(pro, is_wine)
+
+    # copy SRCRESLT.TXT to output_file
+    result_file = new_nist_home+"/MSSEARCH/SRCRESLT.TXT"
+    utils.copy_file(result_file, output_file)
     
+    
+ 
+def _kill_NIST(process_group, is_wine): 
+    ''' 
+    nistm$ will terminate...nistms.exe is the one that 
+    stays open...and orphan. This method kills it.
+    '''  
     if is_wine:
 #         pid = utils.get_process_pid("nistms.exe")
 #         os.kill(pid, 9)
-        os.killpg(pro.pid, 9)
+        os.killpg(process_group.pid, 9)
     else:
         # windows case:
         proc_name = "nistms.exe"
         os.system("taskkill /f /im " + proc_name)
   
-    # copy SRCRESLT.TXT to output_file
-    result_file = new_nist_home+"/MSSEARCH/SRCRESLT.TXT"
-    utils.copy_file(result_file, output_file)
+
     
 
 def _create_html_report(output_html_report, output_html_report_files_path, hits_dict, spectra_dict):