Generate rating calculation promises in list comprehension
This commit is contained in:
parent
649b55f84f
commit
d5bbe5139d
7
cli.py
7
cli.py
@ -41,11 +41,10 @@ class Cli:
|
||||
self.args = ap.parse_args()
|
||||
|
||||
def calculate_ratings(self):
|
||||
ratings = []
|
||||
with Pool(processes=cpu_count()) as pool:
|
||||
for image in self.args.images:
|
||||
ratings.append((image, pool.apply_async(self.calculate_rating,
|
||||
(image, self.args.method))))
|
||||
ratings = [(image, pool.apply_async(self.calculate_rating,
|
||||
(image, self.args.method)))
|
||||
for image in self.args.images]
|
||||
self.image_ratings = {image: promise.get() for image, promise in ratings}
|
||||
|
||||
@staticmethod
|
||||
|
Loading…
Reference in New Issue
Block a user