Threaded alternatives to smtplib?

Piet van Oostrum piet at cs.uu.nl
Mon May 4 16:44:55 EDT 2009


>>>>> Alex Jurkiewicz <alex at bluebottle.net.au> (AJ) wrote:

>AJ> def threadProcessRecipient():
[snip]
>AJ> if __name__ == '__main__':
>AJ>    THREADS = []
>AJ>    for i in range(CONCURRENCY):
>AJ>        THREADS.append(threading.Thread(target=threadProcessRecipient))
>AJ>    for thread in THREADS:
>AJ>        thread.run()

You should use thread.start(), not thread.run(). When you use run(), it
will be sequential execution, as you experience. With start() you get
concurrency
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org



More information about the Python-list mailing list