From bf8a79f0f1e923c509cb12f1d49a3ecb99abe063 Mon Sep 17 00:00:00 2001 From: Cantalapiedra Date: Wed, 15 Jun 2022 10:21:20 +0200 Subject: [PATCH] fix #390 --- download_eggnog_data.py | 2 +- eggnogmapper/search/hmmer/hmmer.py | 3 +++ eggnogmapper/search/hmmer/hmmer_server.py | 19 ++++++++++--------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/download_eggnog_data.py b/download_eggnog_data.py index bc4ad57a..b45af253 100755 --- a/download_eggnog_data.py +++ b/download_eggnog_data.py @@ -139,7 +139,7 @@ def download_hmm_database(level, dbname, dbpath): 'echo "hmmpress-ing HMMs... " && ' f'{HMMPRESS} {dbname}.hmm && ' 'echo "generating idmap file... " && ' - f'cat {dbname}.hmm | grep "^NAME" | sed -e "s/^NAME *//" | awk \'{{print NR"\t"$0}}\' > {dbname}.hmm.idmap && ' + f'cat {dbname}.hmm | grep "^NAME" | sed -e "s/^NAME *//" | awk \'{{print NR" "$0}}\' > {dbname}.hmm.idmap && ' 'echo "removing single OG hmm files... " && ' f'echo ./*hmm | xargs rm; ' ) diff --git a/eggnogmapper/search/hmmer/hmmer.py b/eggnogmapper/search/hmmer/hmmer.py index c494310d..ce8844b5 100644 --- a/eggnogmapper/search/hmmer/hmmer.py +++ b/eggnogmapper/search/hmmer/hmmer.py @@ -144,6 +144,7 @@ def clear(self): if (self.setup_type == SETUP_TYPE_EGGNOG or self.setup_type == SETUP_TYPE_CUSTOM) and self.scantype == SCANTYPE_MEM: for dbpath, port, master_pid, workers_pids in self.servers: shutdown_server_by_pid(master_pid, workers_pids) + self.servers = [] return @@ -176,6 +177,7 @@ def search_hmm_matches(self, in_file, hmm_hits_file, silent = False): if (self.setup_type == SETUP_TYPE_EGGNOG or self.setup_type == SETUP_TYPE_CUSTOM) and self.scantype == SCANTYPE_MEM: for dbpath, port, master_pid, workers_pids in self.servers: shutdown_server_by_pid(master_pid, workers_pids) + self.servers = [] return @@ -222,6 +224,7 @@ def search(self, in_file, seed_orthologs_file, hmm_hits_file): if (self.setup_type == SETUP_TYPE_EGGNOG or self.setup_type == SETUP_TYPE_CUSTOM) and self.scantype == SCANTYPE_MEM: for dbpath, port, master_pid, workers_pids in self.servers: shutdown_server_by_pid(master_pid, workers_pids) + self.servers = [] return hits diff --git a/eggnogmapper/search/hmmer/hmmer_server.py b/eggnogmapper/search/hmmer/hmmer_server.py index 96c4a0f4..fbd57916 100644 --- a/eggnogmapper/search/hmmer/hmmer_server.py +++ b/eggnogmapper/search/hmmer/hmmer_server.py @@ -267,29 +267,30 @@ def shutdown_server_by_pid(MASTER, WORKERS): import psutil - try: - # This is killing THIS python script also, and is UNIX dependent - # os.killpg(os.getpgid(WORKER.pid), signal.SIGTERM) + # This is killing THIS python script also, and is UNIX dependent + # os.killpg(os.getpgid(WORKER.pid), signal.SIGTERM) - for worker in WORKERS: + for worker in WORKERS: + try: parent = psutil.Process(worker.pid) for child in parent.children(recursive=True): # or parent.children() for recursive=False child.kill() parent.kill() + except Exception as e: + print("warning: could not kill hmmpgmd worker --> " + e.msg) - except (OSError, AttributeError): - print("warning: could not kill hmmpgmd worker") - pass + except (OSError, AttributeError): + print("warning: could not kill hmmpgmd worker") + pass try: - parent = psutil.Process(MASTER.pid) for child in parent.children(recursive=True): # or parent.children() for recursive=False child.kill() parent.kill() except Exception as e: - print(e) + print("warning: could not kill hmmpgmd master --> " + e.msg) except (OSError, AttributeError): print("warning: could not kill hmmpgmd master") pass