Concurrent.futures给出“ NoneType”错误,但仅在大约72,000次迭代之后

时间:2019-06-02 02:13:25

标签: python concurrent.futures

在这里为并发提供了很大的帮助,实际上使它起作用了,所以我想: How to fix multithreading/multiprocessing with dictionaries? ...又参与了其他一些任务,而现在才有机会回到这一点。它在50,000、70,000和71,000次迭代中表现出色,但是由于某种原因,它会给出“ NoneType”错误,大约在72,000次左右?每次,这些信息似乎都在那里...它在没有并发的情况下工作了,只花了几个小时。

    pool = ThreadPoolExecutor(max_workers = 25)
    results = list(tqdm(pool.map(get_ips_from_sysinfo, urls), total=len(urls)))

然后是一些get_ips_from_sysinfo

def get_ips_from_sysinfo(urls):
    sysinfo = hx_request(urls)
    ip_dict =[]
    sysinfo = sysinfo["data"]
    hostname = sysinfo.get("hostname")
    print(hostname)
    network_array = sysinfo.get("networkArray", {})
    network_info = network_array.get("networkInfo", [])

以69,000 70,000 71,000运行 我不明白为什么要到大约72,000左右才能使用它???

Traceback (most recent call last):
  File "RiskReportV2_concurrent.py", line 282, in <module>
    concurrency(appliance)
  File "RiskReportV2_concurrent.py", line 267, in concurrency
    results = list(tqdm(pool.map(get_ips_from_sysinfo, urls), total=len(urls)))
  File "/mnt/c/Users/money/Documents/riskreport/src/tqdm/tqdm/_tqdm.py", line 1022, in __iter__
    for obj in iterable:
  File "/usr/lib/python3.5/concurrent/futures/_base.py", line 556, in result_iterator
    yield future.result()
  File "/usr/lib/python3.5/concurrent/futures/_base.py", line 398, in result
    return self.__get_result()
  File "/usr/lib/python3.5/concurrent/futures/_base.py", line 357, in __get_result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "RiskReportV2_concurrent.py", line 135, in get_ips_from_sysinfo
    sysinfo = sysinfo["data"]
TypeError: 'NoneType' object is not subscriptable

1 个答案:

答案 0 :(得分:0)

在下面查看答案

最后还是有机会再看一遍,我不知道我是否做对了,而是将功能切换到了这个