Created
July 14, 2021 00:08
-
-
Save AbdouSeck/8d70a05891d0c7079126cd9d571f9b01 to your computer and use it in GitHub Desktop.
Using mp.Pool instead of mp.Process
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import multiprocessing as mp | |
def RunPrice(items, price): | |
print("There is %s items, price is: %s" % (items, price)) | |
def GetTargetItemsAndPrice(cursor): | |
res = cursor.execute("SELECT DISTINCT items, price FROM SELLS") | |
results = dict() | |
with mp.Pool() as pool: | |
for row in res.fetchall(): | |
args = (row[0], row[1]) | |
results[args] = pool.apply_async(RunPrice, args=args) | |
for result in results.values(): | |
result.get() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment