未来执行人未执行

时间:2015-08-11 13:51:34

标签: python concurrent.futures

以下代码段中未调用未​​来:

def main():
    if not amiadmin(): 
        print ("You are not superuser")
        raise PermissionError
    dumpfile = open('filename', mode='w')
    fileiolock = threading.RLock()
    (ip,) = struct.unpack ("!L", socket.inet_aton("""some ip address"""))
    # sorry, this hack requires Internet addresses be integers
    ips = genlistofipaddrs(ip, 8)
    ips_converted = [ socket.inet_ntoa(struct.pack ("!L", ip)) for ip in ips ]
    ping = icmp(0)
    # reverse conversion from integers
    executor = concurrent.futures.ThreadPoolExecutor(max_workers=ThreadLimit)
    with executor:
         futs = [ executor.submit(IPScanner, ping, ip, dumpfile, fileiolock) 
                  for ip in ips_converted]
    concurrent.futures.wait(futs,return_when=ALL_COMPLETED)
    print ("Good job")

我的真实代码中有一个真正的B级IPv4地址,而不是some ip address。为什么未来不被召唤? 没有例外,程序成功退出。

1 个答案:

答案 0 :(得分:0)

根据@ dano的评论,用executor.submit(IPScanner,ping,ip,dumpfile,fileiolock)替换executor.submit(IPScanner,(ping,ip,dumpfile,fileiolock)),现在可以正常工作。 / p>