を私はPythonのmultiprocessing.Pool
モジュールとマルチプロセッシングを行うが、TypeError: list indices must be integers, not str
エラーました:ここマルチプロセッシングpool.map() "はTypeError:リストインデックスは整数でなければなりません、ないをstr" しまった
が私のコードです:
def getData(qid):
r = requests.get("http://api.xxx.com/api?qid=" + qid)
if r.status == 200:
DBC.save(json.loads(r.text))
def getAnotherData(qid):
r = requests.get("http://api.xxxx.com/anotherapi?qid=" + qid)
if r.status == 200:
DBC.save(json.loads(r.text))
def getAllData(qid):
print qid
getData(str(qid))
getAnotherData(str(qid))
if __name__ == "__main__":
pool = Pool(processes=200)
pool.map(getAllData, range(10000, 700000))
は、いくつかの時間(ない瞬時に)のためのコードを実行した後、例外が間違っている可能性が何
pool.map(getAllData, range(10000, 700000))
File "/usr/lib/python2.7/multiprocessing/pool.py", line 251, in map
return self.map_async(func, iterable, chunksize).get()
File "/usr/lib/python2.7/multiprocessing/pool.py", line 567, in get
raise self._value
TypeError: list indices must be integers, not str
をスローされますか?それはPool
モジュールの不具合ですか?
ありがとう、男、本当に私に手がかりを与える! – armnotstrong