Threaded alternatives to smtplib?
Diez B. Roggisch
deets at nospam.web.de
Mon May 4 06:55:34 EDT 2009
Diez B. Roggisch wrote:
> Alex Jurkiewicz wrote:
>> Gabriel Genellina wrote:
>>> Try logging the start/stop of your threads. It may be that your
>>> threads stop before you think. The above code works correctly only if
>>> you fill the queue before starting any thread - because as soon as a
>>> thread sees the queue empty, it finishes.
>>> You could use the sample code in the Queue documentation at the end of
>> The queue is actually filled before the threads are started, data is
>> only removed after they start.
>> Logging thread state (at least in debug mode) would be good though. How
>> would I go about it in this example? The docs suggest using thread.name,
>> but in my current setup I don't have any idea which thread is running.
>> Something like this:
>> for i in range(CONCURRENCY):
>> THREADS.append( threading.Thread(target=threadProcessRecipient,
>> args=i, name=i) )
>> def threadProcessRecipient(name):
>> print "Name is %s" % name
Oh, and I forgot - threading.currentThread() gets you the actively running
thread of course.
More information about the Python-list