Threaded alternatives to smtplib?

Alex Jurkiewicz alex at bluebottle.net.au
Mon May 4 04:31:46 EDT 2009


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 
> http://docs.python.org/library/queue.htm
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) )

And:

def threadProcessRecipient(name):
    print "Name is %s" % name


AJ



More information about the Python-list mailing list