Python 3.x 使用池时发生EOF错误

Python 3.x 使用池时发生EOF错误,python-3.x,multiprocessing,python-3.6,python-multiprocessing,pool,Python 3.x,Multiprocessing,Python 3.6,Python Multiprocessing,Pool,在我的代码中,我试图使用多重处理来查找给定URL的每枚硬币的最高价格。我需要为大约1400个硬币获取数据,所以我实现了Python的多处理池。我不确定我是否正确使用了它,但我遵循了本网站给出的示例: 这是我的密码: import requests import json from bs4 import BeautifulSoup from multiprocessing import Pool max_prices = [] def find_max (url): # finds m

在我的代码中,我试图使用多重处理来查找给定URL的每枚硬币的最高价格。我需要为大约1400个硬币获取数据,所以我实现了Python的多处理池。我不确定我是否正确使用了它,但我遵循了本网站给出的示例:

这是我的密码:

import requests
import json
from bs4 import BeautifulSoup
from multiprocessing import Pool

max_prices = []

def find_max (url):
    # finds maximum price of a coin
    r = requests.get(url)
    cont = r.json()

    prices = list(map(lambda x: x[1], cont["price_usd"]))
    maxPrice = max(prices)

    return maxPrice


with open("coins.txt", "r") as f:
    data = json.load(f)
coin_slug = [d["slug"] for d in data]
coin_names = [d["name"] for d in data]

urls = []
for item in coin_slug:
    url = "https://graphs2.coinmarketcap.com/currencies/"+item+"/"
    urls.append(url)

if __name__ == '__main__':
    with Pool(5) as p:
        print(p.map(find_max, urls)
当我添加这部分代码时,它给了我一个EOF错误:

if __name__ == '__main__':
   with Pool(5) as p:
        print(p.map(find_max, urls)

最后一行的括号不平衡。应该是
printp.mapfind_max,URL。

请发布整个回溯错误消息。发布coins.txt的部分内容也可能有帮助,以便我们重现问题。