出于某种原因,
result = pool.map(_delete_load_log,list(logs_to_delete))
现在给我一个 'int' object is not iterable 错误。
根据屏幕截图,logs_to_delete 显然是一个数组(添加了 list() 以查看它是否改变了什么,但没有改变)。这在早些时候起作用,但我无法追溯是什么改变使它不起作用。有什么想法吗?
映射函数:
def _delete_load_log(load_log_id):
logging.debug('** STARTING API CALL FOR: ' + get_function_name())
input_args = "/15/" + str(load_log_id)
logging.debug('url: ' + podium_url + '\nusername: ' + podium_username)
podium = podiumapi.Podium('https://xx/podium','podium','podium')
#podium = podiumapi.Podium(podium_url,podium_username,podium_password)
data = None
response_code = 0
try:
api_url = PodiumApiUrl(podium_url,input_args)
(response_code,data) = podium._podium_curl_setopt_put(api_url)
if not data[0]['hasErrors']:
return data[0]['id']
elif data[0]['hasErrors']:
raise Exception("Errors detected on delete")
else:
raise Exception('Unmanaged exception while retrieving entity load status.')
except Exception as err:
raise Exception(str(err))
File "c:\Repos\Tools\podium-dataload\scripts\podiumlogdelete.py", line 69, in _delete_source_load_logs_gte_epoch
deleted_load_ids = _delete_logs_in_parallel(load_logs_to_delete)
File "c:\Repos\Tools\podium-dataload\scripts\podiumlogdelete.py", line 85, in _delete_logs_in_parallel
result = pool.map(_delete_load_log,logs_to_delete)
File "C:\Python27\lib\multiprocessing\pool.py", line 253, in map
return self.map_async(func, iterable, chunksize).get()
File "C:\Python27\lib\multiprocessing\pool.py", line 572, in get
raise self._value
Exception: 'int' object is not iterable
列表输出:
[154840、154841、154842、154843、154844、154845、154846、154847、154848、154849、154850、154851、154852、154853、1548585、45、614 57、154858、154859、154860、154861、154862、 154863, 154864, 154865, 154866, 154867, 154868, 154869, 154870, 154871, 154872, 154873, 154874, 154875, 154876, 154877, 154877, 8,9,181,487 154881, 154882, 154883, 154884, 154885, 154886, 154887, 154888、154889、154890、154891、154892、154893、154894、154895、154896、154897、154898、154899、154900、154901、154902、154896、154897、154898、154899、154900、154901、154902、140、1514903 154906, 154907, 154908, 154909, 154910, 154911, 154912, 154913、154914、154915、154916、154917、154918、154919、154920、154921、154922、154923、154924、154925、154926、154927、154921、154922、154923、154924、154925、154926、154927、24、154928、154928、154928 154931, 154932, 154933, 154934, 154935, 154936, 154937, 154938, 154939]
请您参考如下方法:
从回溯中可以清楚地看出您的问题。不是Pool.map()中的iterable引起的,否则会从Python源代码行抛出异常
iterable = list(iterable)
这里引发异常
File "C:\Python27\lib\multiprocessing\pool.py", line 253, in map
return self.map_async(func, iterable, chunksize).get()
File "C:\Python27\lib\multiprocessing\pool.py", line 572, in get
raise self._value
这是因为您的 _delete_load_log() 引发了一些异常,并且 Pool.map 重新引发了它。参见 https://github.com/python/cpython/blob/2.7/Lib/multiprocessing/pool.py
换句话说,Exception: 'int' object is not iterable 不是 来自 python 库部分,它来自您自己的函数 _delete_load_log().
