如何使用grequest.post进行多处理

时间:2019-04-03 01:16:29

标签: python python-3.x multithreading csv python-requests

ENDPOINT_URL = 'https://example.com'
headers = {'Api-key': '123abc'}

with open("student.csv", "r") as csv_ledger:
    r = csv.DictReader(csv_ledger)
    data = [dict(d) for d in r ]
    groups = {}

    for k, g in groupby(data, lambda r: (r['name'])):
        #My data mapping

        #for loop to post each record
        rs = (grequests.post(u,json=groups, headers=headers) for u in ENDPOINT_URL)
        grequests.map(rs)

        print(grequests.map(rs)

返回的结果None我做错了什么?难道是json数据格式问题?

0 个答案:

没有答案