diff --git a/lcservice/service.py b/lcservice/service.py index 83c9aae..449e8fe 100644 --- a/lcservice/service.py +++ b/lcservice/service.py @@ -470,8 +470,7 @@ def parallelExec( self, f, objects, timeout = None, maxConcurrent = None ): results = [] with ThreadPoolExecutor( max_workers=maxConcurrent ) as executor: - future = executor.map( lambda o: self._retExecOrExc( f, o, timeout ), objects, timeout = timeout ) - results = future.result() + results = executor.map( lambda o: self._retExecOrExc( f, o, timeout ), objects, timeout = timeout ) return list( results ) def _retExecOrExc( self, f, o, timeout ): @@ -500,8 +499,7 @@ def parallelExecEx( self, f, objects, timeout = None, maxConcurrent = None ): results = [] with ThreadPoolExecutor( max_workers=maxConcurrent ) as executor: - future = executor.map( lambda o: self._retExecOrExcWithKey( f, o, timeout ), objects.items(), timeout = timeout ) - results = future.result() + results = executor.map( lambda o: self._retExecOrExcWithKey( f, o, timeout ), objects.items(), timeout = timeout ) return list( results ) # LC Service Lifecycle Functions diff --git a/tests/test_lifecycle.py b/tests/test_lifecycle.py index 22e4796..8dfc1b2 100644 --- a/tests/test_lifecycle.py +++ b/tests/test_lifecycle.py @@ -178,4 +178,18 @@ def _inc(): time.sleep( 2.1 ) assert( 3 == n ) + svc._onShutdown() + +def test_parallel(): + global n + svc = lcservice.Service( 'test-service', None ) + + n = 0 + def _inc(): + global n + n += 1 + + res = svc.parallelExec( _inc, [ 1, 2, 3, 4 ], 10, 5 ) + assert( 4 == len( res ) ) + svc._onShutdown() \ No newline at end of file