如何解决当任务完成或满足条件时如何使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
。
在这里,图片:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。