From 825e7a75c73e083ebf6c2f46284f24f4294abf66 Mon Sep 17 00:00:00 2001 From: Rustam Temirov Date: Wed, 29 Nov 2023 22:08:05 +0100 Subject: [PATCH] Logmatch : Resolve matching with n_workers greater than 1 When logmatch is tested with n_workers greater than 1, the error is outputed that xrange is depracated and chunk_size being float type. Commit resolves the data type issue and also changes xrange to range --- logparser/logmatch/regexmatch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/logparser/logmatch/regexmatch.py b/logparser/logmatch/regexmatch.py index 14a21aa3..96de62c9 100644 --- a/logparser/logmatch/regexmatch.py +++ b/logparser/logmatch/regexmatch.py @@ -76,7 +76,7 @@ def match_event(self, event_list): results = match_fn(event_list, self.template_match_dict, self.optimized) else: pool = mp.Pool(processes=self.n_workers) - chunk_size = len(event_list) / self.n_workers + 1 + chunk_size = len(event_list) // self.n_workers + 1 result_chunks = [ pool.apply_async( match_fn, @@ -86,7 +86,7 @@ def match_event(self, event_list): self.optimized, ), ) - for i in xrange(0, len(event_list), chunk_size) + for i in range(0, len(event_list), chunk_size) ] pool.close() pool.join()