def main():
global iprange, ipHasFind
print("Process Sum:", ProcessSum)
if ProcessSum > 1:
q = Queue()
q.put(ipHasFind)
for i in range(ProcessSum):
print("Start Process:", i)
p = CheckProcess(q, iprange)
p.start()
try:
with open("ip.txt", "w") as f:
sum = 0
while True:
ip = ipList.get()
s = ip + "|"
f.write(s)
sum += 1
print("All Sucess Ip:%4d" % sum)
except (KeyboardInterrupt, SystemExit) as e:
print("main exited")
finally:
file_name = "find_log" +"0" + ".txt"
with open(file_name) as f:
s = f.readlines()
d = dict([[int(i.split(":")[0]), int(i.split(":")[-1])]
for i in list(map(lambda x:x[:-1], s))])
while GoodIpRange.qsize() > 0:
nowdict = GoodIpRange.get()
d.update(nowdict)
with open(file_name, "w") as f:
for i in d.items():
print(i[0], ":", i[1])
f.write(str(i[0]) + ":" + str(i[1]) + "\n")
else:
try:
q = Queue()
q.put(ipHasFind)
loop = asyncio.get_event_loop()
ipfactory = get_ip.ipFactory(q, iprange)
testip = Test_Ip(loop, ipfactory)
loop.create_task(testip.Server())
profile.runctx(
"loop.run_until_complete(testip.SuccessStop())",
globals(),
locals())
# loop.run_until_complete(testip.SuccessStop())
except (KeyboardInterrupt, SystemExit) as e:
loop.create_task(testip.stop())
loop.run_until_complete(testip.SuccessStop())
finally:
loop.close()
print("Task exit")
评论列表
文章目录