ich ein Multiprocessing mit multiprocessing.Pool
Moduls Python, bekam aber TypeError: list indices must be integers, not str
Fehler:Multiprozessing pool.map() bekam "Typeerror: Liste Indizes müssen ganze Zahlen sein, nicht 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))
:
Hier ist mein Code
nach dem Code für einige Zeit (nicht sofort) ausgeführt wird, wird eine Ausnahme aus
geworfen wirdpool.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
Was könnte falsch sein? Ist es ein Fehler des Moduls ?
Danke, Mann, das gibt mir wirklich einen Hinweis! – armnotstrong