<commit_before>#!/usr/local/bin/python
import smtplib, time, threading, sys, random
from email.mime.text import MIMEText

fromaddr = sys.argv[1].split(",")
toaddr = sys.argv[2]
mailsToSend = 20
threadCount = 10

def createMessage(fromaddr, toaddr, subject, msgtxt):
    msg = MIMEText(msgtxt)
    msg['Subject'] = subject
    msg['From'] = fromaddr
    msg['To'] = toaddr
    return msg

def sendMails(threadId):
    server = smtplib.SMTP('localhost', 8001)
    for i in xrange(mailsToSend):
        actualFrom = random.choice(fromaddr)
        server.sendmail(actualFrom, [toaddr], createMessage(actualFrom, toaddr, "This is from thread %s" % threadId, "Some header" ).as_string())
    server.quit()

threads = [threading.Thread(target=sendMails, args=(i,)) for i in range(threadCount)]

for t in threads:
    t.start()

for t in threads:
    t.join()
     
    
<commit_msg>Add prolonged flood test to testMail script<commit_after>#!/usr/local/bin/python
import smtplib, time, threading, sys, random, datetime
from email.mime.text import MIMEText

fromaddr = sys.argv[1].split(",")
toaddr = sys.argv[2]
mailsToSend = 20
threadCount = 10
sleepBetweenSends=0.1
sustainedFloodForSeconds=60


def createMessage(fromaddr, toaddr, subject, msgtxt):
    msg = MIMEText(msgtxt)
    msg['Subject'] = subject
    msg['From'] = fromaddr
    msg['To'] = toaddr
    return msg

def sendMails(threadId):
    server = smtplib.SMTP('localhost', 8001)
    for i in xrange(mailsToSend):
        actualFrom = random.choice(fromaddr)
        server.sendmail(actualFrom, [toaddr], createMessage(actualFrom, toaddr, "This is from thread %s" % threadId, "Some header" ).as_string())
        
    server.quit()

def sendMailsFor(threadId):
    start = datetime.datetime.today()
    while ( datetime.datetime.today() - start ) < datetime.timedelta(seconds=sustainedFloodForSeconds):
        sendMails(threadId)
        if sleepBetweenSends:
            time.sleep(sleepBetweenSends)
    

threads = [threading.Thread(target=sendMailsFor, args=(i,)) for i in range(threadCount)]

for t in threads:
    t.start()

for t in threads:
    t.join()
     
    

{'fraction_non_alphanumeric': 0.12529328953542937, 'fraction_numerical': 0.011262318160488035, 'mean_word_length': 3.8126410835214446, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1139812', 'n_tokens_mistral': 739, 'n_tokens_neox': 714, 'n_words': 173}