From c0c98919e710866de5b5d05ca12fd0129540cfaf Mon Sep 17 00:00:00 2001 From: lohithbr Date: Tue, 18 Apr 2017 11:24:02 +0530 Subject: [PATCH 1/5] Plmap without lock --- plmap/plmapp.py | 161 +++++++++++++++++++++++++++++++----------------- 1 file changed, 106 insertions(+), 55 deletions(-) diff --git a/plmap/plmapp.py b/plmap/plmapp.py index ac9fbe0..c543ef8 100644 --- a/plmap/plmapp.py +++ b/plmap/plmapp.py @@ -44,93 +44,144 @@ +PROGRESS_BAR_POLL_TIME = 1 +PROGRESS_BAR_LENGTH = 20 -class FunctionTimeoutException(Exception): - """ This exception will be raised when a function takes too long to complete + +global_lock = multiprocessing.Lock() + +def increment_after_lock(): + global_lock.acquire() + + +def generate_loading_string(completed_tasks, total_tasks): + """ % [< -- based on percentage completion>] Completed/Total """ - pass + try: + fraction_completed = ( completed_tasks / total_tasks) + except: + fraction_completed = 1 # To avoid division by Zero + percentage_complete = fraction_completed * 100 + dashes = int(PROGRESS_BAR_LENGTH * fraction_completed) + blanks = PROGRESS_BAR_LENGTH - dashes -def receive_signal(signum, stack): - details = "Function timeout" - raise FunctionTimeoutException(details) + bar = "[" + "-" * dashes + ">" + " " * blanks + "]" + fraction_display = "%s/%s" %(completed_tasks, total_tasks) + loading_string = "%s%% %s %s" %(percentage_complete, bar, fraction_display) + return loading_string -def queue_exec(input_queue, output_queue, log_queue, individual_timeout=20.0, default_output=None): - """ This function will be executed by all the child Processes spawned by the Parent process + +def display_progress_bar(progress_details, total_tasks): + """ 50%[----------> ]5/10 """ + completed_tasks = len(progress_details) + + while completed_tasks != total_tasks: - signal.signal(signal.SIGALRM, receive_signal) - - while True: - try: - id, function, args, kwargs = input_queue.get_nowait() - except : - break - - signal.alarm(int(individual_timeout)) - - try: - output = function(*args, **kwargs) - output_queue.put({ 'id' : id, 'output' : output, 'error_code' : '0', 'err_desc' : None }) - except FunctionTimeoutException, details: - output_queue.put({ 'id' : id, 'output' : default_output, 'error_code' : '1', 'err_desc' : str(details) }) - log_queue.put("state:MAJOR, id:{}, output:{}, err:{}, desc:{}".format(id, default_output, '1', str(details))) - except Exception, details: - log_queue.put("state:MAJOR, id:{}, output:{}, err:{}, desc:{}".format(id, default_output, '1', str(details))) - output_queue.put({ 'id' : id, 'output' : default_output, 'error_code' : '1', 'err_desc' : str(details) }) - pass - # Log the error here - signal.alarm(0) + time.sleep(PROGRESS_BAR_POLL_TIME) + completed_tasks = len(progress_details) + + print generate_loading_string(completed_tasks, total_tasks) + sys.stdout.write("\033[F") + + # Display 100% completion + completed_tasks = len(progress_details) + print generate_loading_string(completed_tasks, total_tasks) sys.exit(0) +class FunctionTimeoutException(Exception): + """ This exception will be raised when a function takes too long to complete + """ + pass + + +def receive_signal(signum, stack): + details = "Function timeout" + raise FunctionTimeoutException(details) -def plmapp(func, args=[], kwargs=[], processes=10, default_output=None, individual_timeout=20): + +def queue_exec(input_queue, p_id, error_list, output_list, progress_details, individual_timeout=20.0, default_output=None): + """ This function will be executed by all the child Processes spawned by the Parent process + """ + if p_id != -1: # Not a progress bar process + signal.signal(signal.SIGALRM, receive_signal) + + while True: + try: + loc, function, args, kwargs = input_queue.get_nowait() + except Exception, details: + break + + signal.alarm(int(individual_timeout)) + + try: + output = function(*args, **kwargs) + + error_list[loc] = (0, None) + output_list[loc] = output + print "Got the output %s for %s %s" %(output, loc, output_list) + except FunctionTimeoutException, details: + error_list[loc] = (1, details) + output_list[loc] = default_output + except Exception, details: + error_list[loc] = (2, details) + output_list[loc] = default_output + finally: + progress_details.append(1) + signal.alarm(0) + sys.exit(0) + + else: + display_progress_bar(progress_details) + + + + + +def plmapp(func, args=[], kwargs=[], processes=10, default_output=None, progress_bar=False, individual_timeout=20): """ """ - input_queue = Queue() - output_queue = Queue() - log_queue = Queue() bigger_array = args if len(args) > len(kwargs) else kwargs big_len = len(bigger_array) ag = lambda array, index, default : default if index >= len(array) else array[index] + input_queue = Queue() + output_errors = [ default_output for _ in xrange(big_len)] + output_values = [ default_output for _ in xrange(big_len)] + progress_details = [] + # Load the input queue with tasks - for _ in xrange(big_len): - task = ( _ , func, ag(args, _, ()), ag(kwargs, _, {}) ) + for i in xrange(big_len): + task = (i, func, ag(args, i, ()), ag(kwargs, i, {})) input_queue.put(task) # Create the processes processes = [] - for _ in xrange(min(processes, 10)): - p = Process(target=queue_exec, args=(input_queue, output_queue, log_queue, individual_timeout, default_output)) + end = min(processes, big_len) + start = -1 if progress_bar else 0 + + + for i in xrange(start, end): + p = Process(target=queue_exec, args=(input_queue, i, output_errors, output_values, progress_details, individual_timeout, default_output)) processes.append(p) p.start() # Wait for the processes to complete - for _ in processes: - _.join() - - # Get all the output dictionaries from the output queue - output_dicts = [] - for output_dict in xrange(big_len): - output_dicts.append( output_queue.get_nowait() ) - - # Sort the output based on the id - output_sorted_dicts = sorted(output_dicts, key=lambda x : x['id']) + for process in processes: + process.join() - error_array = [ (_['error_code'], _['err_desc']) for _ in output_sorted_dicts ] - output_array = [ _['output'] for _ in output_sorted_dicts ] + return output_errors, output_values - return (error_array, output_array) @@ -138,12 +189,12 @@ def plmapp(func, args=[], kwargs=[], processes=10, default_output=None, individu if __name__ == "__main__": - def do_it(a, b=8, c=10): - time.sleep(1) - return a + b + c + def do_it(a): + time.sleep(a) + return a # args - args = [ (_,) for _ in xrange(10) ] + args = [[i] for i in range(10)] kwargs = [] func = do_it threads = 8 From f61f548d719a8174b263083363ef91355496282c Mon Sep 17 00:00:00 2001 From: lohithbr Date: Tue, 18 Apr 2017 12:44:12 +0530 Subject: [PATCH 2/5] Multi-threading with Lock --- plmap/plmapt.py | 135 ++++++++++++++++++++++-------------------------- 1 file changed, 61 insertions(+), 74 deletions(-) diff --git a/plmap/plmapt.py b/plmap/plmapt.py index 4e1140d..48b55aa 100644 --- a/plmap/plmapt.py +++ b/plmap/plmapt.py @@ -34,75 +34,62 @@ def add ( a, b ) : from __future__ import division from threading import Thread +from threading import Lock from Queue import Queue import sys -import time - -from pprint import pprint PROGRESS_BAR_POLL_TIME = 1 -PROGRESS_BAR_LENGTH = 20 +PROGRESS_BAR_LENGTH = 40 class Worker(Thread): """ Worker thread is the thread that actually executes the function with the given arguments """ - def __init__(self, thread_id, input_queue, default_output=None, progress_details={}, progress_bar_thread=False): - super(Worker, self).__init__(name='%s' %(thread_id)) + def __init__(self, thread_id, input_queue, default_output=None, progress_details={}): + super(Worker, self).__init__(name='%s' % (thread_id)) self.input_queue = input_queue self.default_output = default_output self.progress_details = progress_details - self.progress_bar_thread = progress_bar_thread - + self.progress_bar_thread = (thread_id == -1) def generate_loading_string(self, completed_tasks, total_tasks): """ % [< -- based on percentage completion>] Completed/Total """ try: - fraction_completed = ( completed_tasks / total_tasks) + fraction_completed = (completed_tasks / total_tasks) except: - fraction_completed = 1 # To avoid division by Zero - + fraction_completed = 1 # To avoid division by Zero percentage_complete = fraction_completed * 100 - dashes = int(PROGRESS_BAR_LENGTH * fraction_completed) blanks = PROGRESS_BAR_LENGTH - dashes - bar = "[" + "-" * dashes + ">" + " " * blanks + "]" - fraction_display = "%s/%s" %(completed_tasks, total_tasks) - - loading_string = "%s%% %s %s" %(percentage_complete, bar, fraction_display) - + fraction_display = "%s/%s" % (completed_tasks, total_tasks) + loading_string = "%s%% %s %s" % ( + percentage_complete, bar, fraction_display) return loading_string - def display_progress_bar(self): """ 50%[----------> ]5/10 """ completed_tasks = self.progress_details['completed_tasks'] total_tasks = self.progress_details['total_tasks'] - while completed_tasks != total_tasks: - time.sleep(PROGRESS_BAR_POLL_TIME) - completed_tasks = self.progress_details['completed_tasks'] total_tasks = self.progress_details['total_tasks'] - print self.generate_loading_string(completed_tasks, total_tasks) sys.stdout.write("\033[F") - # Display 100% completion completed_tasks = self.progress_details['completed_tasks'] total_tasks = self.progress_details['total_tasks'] print self.generate_loading_string(completed_tasks, total_tasks) - - # run method will be called when the thread is started using thread.start() , Hence overriding run method + # run method will be called when the thread is started using + # thread.start() , Hence overriding run method def run(self): """ Pick up the task from the queue and execute it - """ + """ if not self.progress_bar_thread: while True: try: @@ -110,35 +97,35 @@ def run(self): except: break - func, args, kwargs, error_loc, output_loc = task - + func, loc, args, kwargs, errors, outputs = task + try: output = func(*args, **kwargs) - error_loc.append(0) # Indicates Success - output_loc.append(output) + errors[loc], outputs[loc] = 0, output except Exception, details: - error_loc.append(1) # Indicates Failure - output_loc.append(self.default_output) + errors[loc], outputs[loc] = details, self.default_output finally: - self.progress_details['completed_tasks'] += 1 + with self.progress_details['thread_lock']: + self.progress_details['completed_tasks'] += 1 else: self.display_progress_bar() - -def plmapt(func, args=[], kwargs=[], threads=10, default_output=None, sort_output=True, progress_bar=False): +def plmapt(func, args=[], kwargs=[], threads=10, default_output=None, progress_bar=False): """ Create the workers and get them to work. Returns the error and output array - Sorting the output according to the input order is optional () Displaying the Progress bar is optional """ - bigger_array = args if len(args) > len(kwargs) else kwargs + bigger_array = args if len(args) > len(kwargs) else kwargs big_len = len(bigger_array) - # Get the element of an array given the index, return default if index out of range - ag = lambda array, index, default : default if index >= len(array) else array[index] + # Get the element of an array given the index, return default if index out + # of range + ag = lambda array, index, default: default if index >= len(array) else array[ + index] - progress_details = {'total_tasks' : big_len , 'completed_tasks' : 0} + progress_details = {'total_tasks': big_len, + 'completed_tasks': 0, 'thread_lock': Lock()} input_queue = Queue() output_errors = [[] for _ in xrange(big_len)] @@ -146,24 +133,21 @@ def plmapt(func, args=[], kwargs=[], threads=10, default_output=None, sort_outpu # Load the input_queue ( big_len = the number of tasks ) for i in xrange(big_len): - task = [func, ag(args, i, ()), ag(kwargs, i, {}), output_errors[i], output_values[i]] + task = [func, i, ag(args, i, ()), ag(kwargs, i, {}), + output_errors, output_values] input_queue.put(task) # Create workers and start them list_of_workers = [] - for i in xrange(min(threads, big_len)): + end = min(threads, big_len) + start = -1 if progress_bar else 0 + + for i in xrange(start, end): worker = Worker(i, input_queue, default_output, progress_details) worker.setDaemon(True) list_of_workers.append(worker) worker.start() - # If the progress bar needs to be displayed - if progress_bar: - progress_worker = Worker("-1", input_queue, default_output, progress_details, True) - progress_worker.setDaemon(True) - list_of_workers.append(progress_worker) - progress_worker.start() - # Wait till the threads complete for _ in list_of_workers: _.join() @@ -171,36 +155,39 @@ def plmapt(func, args=[], kwargs=[], threads=10, default_output=None, sort_outpu return output_errors, output_values - if __name__ == "__main__": + import time + from pprint import pprint - def add ( a, b ) : - time.sleep(a) + def add(a, b): + time.sleep(1) if a == 3: 1 / 0 - return (a, b,a + b) + return (a, b, a + b) inputs = [ - [3, 5], - [8, 9] , - [4, 12], - [1, 16], - [1, 16], - [1, 16], - [1, 16], - [1, 16], - [3, 16], - [1, 16], + [3, 5], + [8, 9], + [4, 12], + [1, 16], + [1, 16], + [1, 16], + [1, 16], + [1, 16], + [3, 16], + [1, 16], ] - error, output = plmapt(add, inputs , [], 4, default_output=None, progress_bar=True) - print output - error, output = plmapt(add, inputs , [], 8, default_output=None, sort_output=False, progress_bar=True) - print output - error, output = plmapt(add, [] , [], 4, default_output=None, progress_bar=True) - print output - error, output = plmapt(add, inputs , [], 8, default_output=None, sort_output=False, progress_bar=False) - print output - print error - - + error, output = plmapt( + add, inputs, [], 1, default_output=None, progress_bar=True) + pprint(output) + error, output = plmapt( + add, inputs, [], 2, default_output=None, progress_bar=True) + pprint(output) + error, output = plmapt( + add, [], [], 4, default_output=None, progress_bar=True) + pprint(output) + error, output = plmapt( + add, inputs, [], 8, default_output=None, progress_bar=False) + pprint(output) + pprint(error) From 4d79df02e1eec370782f36737003e97e39946c1c Mon Sep 17 00:00:00 2001 From: lohithbr Date: Tue, 18 Apr 2017 13:35:03 +0530 Subject: [PATCH 3/5] Seperation of Progress bar --- plmap/plmapt.py | 37 ++++++++++++------------------------- plmap/progress_bar.py | 22 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 25 deletions(-) create mode 100644 plmap/progress_bar.py diff --git a/plmap/plmapt.py b/plmap/plmapt.py index 48b55aa..849d07a 100644 --- a/plmap/plmapt.py +++ b/plmap/plmapt.py @@ -33,41 +33,25 @@ def add ( a, b ) : from __future__ import division -from threading import Thread -from threading import Lock -from Queue import Queue + import sys +from Queue import Queue +from threading import Lock, Thread +from progress_bar import generate_loading_string PROGRESS_BAR_POLL_TIME = 1 -PROGRESS_BAR_LENGTH = 40 - class Worker(Thread): """ Worker thread is the thread that actually executes the function with the given arguments """ - def __init__(self, thread_id, input_queue, default_output=None, progress_details={}): + def __init__(self, thread_id, input_queue, progress_details, default_output): super(Worker, self).__init__(name='%s' % (thread_id)) self.input_queue = input_queue self.default_output = default_output self.progress_details = progress_details self.progress_bar_thread = (thread_id == -1) - def generate_loading_string(self, completed_tasks, total_tasks): - """ % [< -- based on percentage completion>] Completed/Total - """ - try: - fraction_completed = (completed_tasks / total_tasks) - except: - fraction_completed = 1 # To avoid division by Zero - percentage_complete = fraction_completed * 100 - dashes = int(PROGRESS_BAR_LENGTH * fraction_completed) - blanks = PROGRESS_BAR_LENGTH - dashes - bar = "[" + "-" * dashes + ">" + " " * blanks + "]" - fraction_display = "%s/%s" % (completed_tasks, total_tasks) - loading_string = "%s%% %s %s" % ( - percentage_complete, bar, fraction_display) - return loading_string def display_progress_bar(self): """ 50%[----------> ]5/10 @@ -78,17 +62,17 @@ def display_progress_bar(self): time.sleep(PROGRESS_BAR_POLL_TIME) completed_tasks = self.progress_details['completed_tasks'] total_tasks = self.progress_details['total_tasks'] - print self.generate_loading_string(completed_tasks, total_tasks) + print generate_loading_string(completed_tasks, total_tasks) sys.stdout.write("\033[F") # Display 100% completion completed_tasks = self.progress_details['completed_tasks'] total_tasks = self.progress_details['total_tasks'] - print self.generate_loading_string(completed_tasks, total_tasks) + print generate_loading_string(completed_tasks, total_tasks) # run method will be called when the thread is started using # thread.start() , Hence overriding run method def run(self): - """ Pick up the task from the queue and execute it + """ Pick up the task from the queue and execute it """ if not self.progress_bar_thread: while True: @@ -111,6 +95,9 @@ def run(self): self.display_progress_bar() + + + def plmapt(func, args=[], kwargs=[], threads=10, default_output=None, progress_bar=False): """ Create the workers and get them to work. Returns the error and output array @@ -143,7 +130,7 @@ def plmapt(func, args=[], kwargs=[], threads=10, default_output=None, progress_b start = -1 if progress_bar else 0 for i in xrange(start, end): - worker = Worker(i, input_queue, default_output, progress_details) + worker = Worker(i, input_queue, progress_details, default_output) worker.setDaemon(True) list_of_workers.append(worker) worker.start() diff --git a/plmap/progress_bar.py b/plmap/progress_bar.py new file mode 100644 index 0000000..f47b2f5 --- /dev/null +++ b/plmap/progress_bar.py @@ -0,0 +1,22 @@ + + + + +PROGRESS_BAR_LENGTH = 40 + + +def generate_loading_string(completed_tasks, total_tasks): + """ % [< -- based on percentage completion>] Completed/Total + """ + try: + fraction_completed = (completed_tasks / total_tasks) + except: + fraction_completed = 1 # To avoid division by Zero + percentage_complete = fraction_completed * 100 + dashes = int(PROGRESS_BAR_LENGTH * fraction_completed) + blanks = PROGRESS_BAR_LENGTH - dashes + bar = "[" + "-" * dashes + ">" + " " * blanks + "]" + fraction_display = "%s/%s" % (completed_tasks, total_tasks) + loading_string = "%s%% %s %s" % ( + percentage_complete, bar, fraction_display) + return loading_string From f66a4a668d0118d9565cdee0975315a9ce4a792c Mon Sep 17 00:00:00 2001 From: lohithbr Date: Fri, 21 Apr 2017 09:46:30 +0530 Subject: [PATCH 4/5] Multi-process Improvements --- plmap/plmapp.py | 91 ++++++++++++++++++------------------------- plmap/progress_bar.py | 5 +-- 2 files changed, 39 insertions(+), 57 deletions(-) diff --git a/plmap/plmapp.py b/plmap/plmapp.py index c543ef8..3714b7b 100644 --- a/plmap/plmapp.py +++ b/plmap/plmapp.py @@ -31,9 +31,11 @@ # The output will look like this : # [8, 17, 23, 31] - +from __future__ import division from multiprocessing import Queue from multiprocessing import Process +from multiprocessing import Value +from multiprocessing import Lock from pprint import pprint import datetime import sys @@ -41,56 +43,30 @@ import time import signal import types +from progress_bar import generate_loading_string PROGRESS_BAR_POLL_TIME = 1 -PROGRESS_BAR_LENGTH = 20 - - -global_lock = multiprocessing.Lock() - -def increment_after_lock(): - global_lock.acquire() - -def generate_loading_string(completed_tasks, total_tasks): - """ % [< -- based on percentage completion>] Completed/Total - """ - try: - fraction_completed = ( completed_tasks / total_tasks) - except: - fraction_completed = 1 # To avoid division by Zero - - percentage_complete = fraction_completed * 100 - - dashes = int(PROGRESS_BAR_LENGTH * fraction_completed) - blanks = PROGRESS_BAR_LENGTH - dashes - bar = "[" + "-" * dashes + ">" + " " * blanks + "]" - fraction_display = "%s/%s" %(completed_tasks, total_tasks) - loading_string = "%s%% %s %s" %(percentage_complete, bar, fraction_display) - return loading_string - -def display_progress_bar(progress_details, total_tasks): +def display_progress_bar(progress_details): """ 50%[----------> ]5/10 """ - completed_tasks = len(progress_details) + completed_tasks = progress_details['completed_tasks'].value + total_tasks = progress_details['total_tasks'] while completed_tasks != total_tasks: - time.sleep(PROGRESS_BAR_POLL_TIME) - - completed_tasks = len(progress_details) - + completed_tasks = progress_details['completed_tasks'].value print generate_loading_string(completed_tasks, total_tasks) sys.stdout.write("\033[F") # Display 100% completion - completed_tasks = len(progress_details) + completed_tasks = progress_details['completed_tasks'].value print generate_loading_string(completed_tasks, total_tasks) sys.exit(0) @@ -109,7 +85,7 @@ def receive_signal(signum, stack): -def queue_exec(input_queue, p_id, error_list, output_list, progress_details, individual_timeout=20.0, default_output=None): +def queue_exec(input_queue, output_queue, p_id, progress_details, default_output, individual_timeout=300.0): """ This function will be executed by all the child Processes spawned by the Parent process """ if p_id != -1: # Not a progress bar process @@ -118,28 +94,24 @@ def queue_exec(input_queue, p_id, error_list, output_list, progress_details, ind while True: try: loc, function, args, kwargs = input_queue.get_nowait() - except Exception, details: + except: break signal.alarm(int(individual_timeout)) try: output = function(*args, **kwargs) - - error_list[loc] = (0, None) - output_list[loc] = output - print "Got the output %s for %s %s" %(output, loc, output_list) + output_queue.put((loc, (0, None), output)) except FunctionTimeoutException, details: - error_list[loc] = (1, details) - output_list[loc] = default_output + output_queue.put((loc, (1, details), default_output)) except Exception, details: - error_list[loc] = (2, details) - output_list[loc] = default_output + output_queue.put((loc, (2, details), default_output)) finally: - progress_details.append(1) - signal.alarm(0) - sys.exit(0) + signal.alarm(0) + with progress_details['process_lock']: + progress_details['completed_tasks'].value += 1 + sys.exit(0) else: display_progress_bar(progress_details) @@ -147,18 +119,21 @@ def queue_exec(input_queue, p_id, error_list, output_list, progress_details, ind -def plmapp(func, args=[], kwargs=[], processes=10, default_output=None, progress_bar=False, individual_timeout=20): +def plmapp(func, args=[], kwargs=[], processes=10, progress_bar=False, default_output=None, individual_timeout=20): """ """ - bigger_array = args if len(args) > len(kwargs) else kwargs big_len = len(bigger_array) ag = lambda array, index, default : default if index >= len(array) else array[index] input_queue = Queue() - output_errors = [ default_output for _ in xrange(big_len)] - output_values = [ default_output for _ in xrange(big_len)] - progress_details = [] + output_queue = Queue() + error_queue = Queue() + + + progress_details = {'completed_tasks' : Value('i', 0), + 'total_tasks' : big_len, + 'process_lock' : Lock()} # Load the input queue with tasks for i in xrange(big_len): @@ -172,7 +147,7 @@ def plmapp(func, args=[], kwargs=[], processes=10, default_output=None, progress for i in xrange(start, end): - p = Process(target=queue_exec, args=(input_queue, i, output_errors, output_values, progress_details, individual_timeout, default_output)) + p = Process(target=queue_exec, args=(input_queue, output_queue, i, progress_details, default_output, individual_timeout)) processes.append(p) p.start() @@ -180,10 +155,18 @@ def plmapp(func, args=[], kwargs=[], processes=10, default_output=None, progress for process in processes: process.join() - return output_errors, output_values + output_errors = [ None for _ in xrange(big_len)] + output_values = [ None for _ in xrange(big_len)] + while True: + try: + loc, error_value = error_queue.get_nowait() + output_errors[loc] = error_value + except: + break + return output_errors, output_values @@ -201,7 +184,7 @@ def do_it(a): # user input ends here print "Start time : ", datetime.datetime.now() - error, output = plmapp(func, args, kwargs, threads, default_output=None) + error, output = plmapp(func, args, kwargs, threads, True) print "End time : " , datetime.datetime.now() print "Errors : " pprint(error) diff --git a/plmap/progress_bar.py b/plmap/progress_bar.py index f47b2f5..cef78a3 100644 --- a/plmap/progress_bar.py +++ b/plmap/progress_bar.py @@ -1,4 +1,4 @@ - +from __future__ import division @@ -17,6 +17,5 @@ def generate_loading_string(completed_tasks, total_tasks): blanks = PROGRESS_BAR_LENGTH - dashes bar = "[" + "-" * dashes + ">" + " " * blanks + "]" fraction_display = "%s/%s" % (completed_tasks, total_tasks) - loading_string = "%s%% %s %s" % ( - percentage_complete, bar, fraction_display) + loading_string = "%s%% %s %s" % (percentage_complete, bar, fraction_display) return loading_string From f558c308ed7b59b1d79ed39acfd7fde4d468b981 Mon Sep 17 00:00:00 2001 From: lohithbr Date: Fri, 21 Apr 2017 09:49:48 +0530 Subject: [PATCH 5/5] Performance improvements in multi-threading and multi-processing --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 77ff741..85d0f38 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup setup(name='plmap', - version='1.1.0', + version='2.0.0', description='Parallel map using multi-threading and multi-processing', author='Lohith B R', packages=['plmap'],