smtplib, capturing output from set_debuglevel ??

Steve Holden steve at holdenweb.com
Fri Oct 8 14:58:05 CEST 2004


Tim Williams wrote:

> [apologies if you got this twice]
> 
> ----- Original Message ----- 
> From: "Josiah Carlson" <jcarlson at uci.edu>
> 
>>>If you want to use file primitives to read the value back, just create
>>>another one:
>>>
>>>inpt = StringIO.StringIO(firstStringIO.getvalue())
>>>
>>>then you can read the printed output from inpt just like a file.
>>
>>Or even:
>>
>> firstStringIO.seek(0)
>>
>> - Josiah
> 
> 
> Steve, Andrew, Josiah,
> 
> Thanks for your answers.
> 
> The outgoing SMTP is multi-threaded,   so the threads disrupt each other's
> output to the file-like object  if there is any concurrent outgoing mail
> activity.
> 
> Is there anyway I can seperate the output from each thread and capture it ?
> 
> The outgoing threads are started  with
> 
> thread.start_new_thread(outThread,(args,None))
> 
> One thread per out-going message.  Each handles the outgoing message sending
> and error-handling for the message.   I can't talk back to the calling
> thread/class because it is the incoming SMTP part and it is destroyed when
> the remote client connection is dropped.  (The SMTP server is a filtering
> relay)
> 
AT this point I might be tempted to modify the smtplib code so it 
doesn't use sys.stdout for its debug output, but some other object that 
can be passed to SMTP.__init__().

Since sys.stdout is going to be common to all modules, I think you have 
highlighted a weakness in the smtplib debugging paradigm. But if some 
smart type can come up with a better solution I'd love to see it.

regards
  Steve
-- 
http://www.holdenweb.com
http://pydish.holdenweb.com
Holden Web LLC +1 800 494 3119




More information about the Python-list mailing list