Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- import time
- import subprocess
- hosts = []
- threads = {}
- tmpKill = []
- eMailList = []
- running = 1
- currentEmail = 1
- finished = 0
- f = open('output', 'a')
- def cleanupThreads():
- for host in threads:
- if time.time() - threads[host][1] > 5:
- tmpKill.append(host)
- killThreads()
- def killThreads():
- for host in tmpKill:
- if host in threads:
- threads[host][0].kill()
- del threads[host]
- f.write(host)
- f.write('\n')
- for host in tmpKill:
- del tmpKill[tmpKill.index(host)]
- def addNextThread():
- global currentEmail
- thisHost = eMailList[currentEmail]
- f.write(thisHost)
- f.write('\n')
- threads[thisHost[0]] = [subprocess.Popen(['python', 'newEmail.py', thisHost], shell=False), time.time()]
- currentEmail += 1
- #print currentEmail
- fileHandle = open('list.txt', "r")
- for line in fileHandle:
- line = line.rstrip('\n')
- eMailList.append(line)
- print eMailList
- print "Total emails: %d" % len(eMailList)
- while running:
- if len(threads) >= 10:
- cleanupThreads()
- else:
- if finished:
- #closeCleanup()
- print "### FINISHED ###"
- running = 0
- else:
- addNextThread()
- if currentEmail >= len(eMailList) - 1:
- print "Cleaning up!"
- print "-"
- print "-"
- finished = 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement