当任务完成或满足条件时如何使ThreadPoolExecutor退出?

问题描述

Bcrypt.py包含

class BCrypt:
    def __init__(self,input_hash):
        from passlib.hash import bcrypt
        self.hash = input_hash
        self.method = bcrypt

    def check(self,word):
        print(f"Trying word: {word}")
        if self.method.verify(word,self.hash):
            return True,word

并且Main.py包含

...
CryptApp = BCrypt(input_hash)
with ThreadPoolExecutor(max_workers=argv.threads) as Submitter:
    future_objects = [Submitter.submit(CryptApp.check,word) for word in input_wordlist]
    for future_object in future_objects:
    is_correct,word = future_object.result()
    if is_correct:
        print(f"Found word {word}")
        exit()
...

问题是,即使在打印“ Found word hello”之后,它也不会退出。找到某些哈希后,我可以编码退出吗?

哈希:$2y$12$JXxao0HwSeTlq6gz/yzHb.SfOmHJFcxfta3NR/So8Y5u2akRffFoS

在这里图片

Found hash

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)