推薦在linux環(huán)境下使用窿春,找到之后可以使用信號量signal氢哮,Ctrl + C
可以退出所有進程.
import os
import string
from multiprocessing import Pool
import random
import hashlib
import signal
signal.signal(signal.SIGINT , signal.SIG_DFL)
signal.signal(signal.SIGHUP , signal.SIG_DFL)
def md5(data):
return hashlib.md5(data).hexdigest()
def getRandomStr():
return "".join(random.sample(string.ascii_letters + string.digits ,8))
EXIT_FLAG = False
def force(x):
global EXIT_FLAG
# print(x)
print(os.getpid())
while not EXIT_FLAG:
data = getRandomStr()
s = md5(data.encode())
if s[-6:] == "a5ec49":
print(data,s)
EXIT_FLAG = True
return True
if __name__ == '__main__':
with Pool(5) as p:
p.map(force , range(5))