Skip to content

Commit

Permalink
#333 and #321 some documentation about weird threading quirks
Browse files Browse the repository at this point in the history
  • Loading branch information
ecwood committed Jul 27, 2023
1 parent de5d0a5 commit a177b29
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions query_kegg.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ def run_set_of_queries(self, kegg_id_dict):
self.process_get_query(results, kegg_id_dict[kegg_id], kegg_id)
except IndexError:
print("Trying again with", kegg_id, "at count", get_count, "on thread", self.name)
# We want to sleep for a random time to try and counteract when the other threads may or may not be sleeping
# or going in general
time.sleep(random.randint(1, 5))
continue
else:
Expand All @@ -194,6 +196,8 @@ def run_set_of_queries(self, kegg_id_dict):

output_info = kg2_util.create_single_jsonlines(True)
output_writer = output_info[0]

# Six threads seems to be the maximum we can achieve without having to spin to work
create_threads(6, output_writer)

kg2_util.close_single_jsonlines(output_info, output_file_name)

0 comments on commit a177b29

Please sign in to comment.