En Mon, 04 May 2009 04:19:21 -0300, Alex Jurkiewicz
<a...@bluebottle.net.au> escribió:
Diez B. Roggisch wrote:
Without more code, it's impossible to tell if there is anything
peculiar in your usage of the lib. Maybe you close your connections to
fast to see several open?
Here's the relevant stuff from my (python2.6) code:
CONCURRENCY = 3
def threadProcessRecipient():
# Each thread has its own SMTP connection
smtpserver = smtplib.SMTP(SMTPSERVER)
# Each thread pulls a recipient entry from the queue to process
and loops until the queue is empty.
try:
recipientData = recipientQueue.get_nowait()
except Queue.Empty:
recipientData = None
while recipientData:
message = prepareMessage()
sendMail(senderEmail, recipientEmail, message, smtpserver)
recipientQueue.task_done()
try:
recipientData = recipientQueue.get_nowait()
except Queue.Empty:
recipientData = None
smtpserver.quit()
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.html
--
Gabriel Genellina
--
http://mail.python.org/mailman/listinfo/python-list