(solved) smtplib, capturing output from set_debuglevel ??
Andrew Dalke
adalke at mindspring.com
Sat Oct 9 03:36:13 EDT 2004
Josiah Carlson wrote:
> After perusing it (smtplib) for a bit, I notice how often the debug
> notices are peppered through. Thankfully for the most recent CVS, they
> include 'print >>stderr, <stuff>' rather than the previous 'print
> <stuff>'. At least it allows doing smtplib.stderr = <anything>, without
> affecting other modules that rely on a reasonable stderr.
Ahh, that would explain why my examples replaced
smtplib.stderr while others replaced sys.stdout. I'm
working out of a CVS build.
> Thread local storage isn't necessary, and actually makes it harder. You
> have to write custom code to get back your per-thread storage, whether
> that is remembering to write the log when the thread dies, or using a
> weakref to do it for you; neither of which are necessarily a newbie
> thing to do.
In a cursory look of your code I though you were implementing
a sort of thread local storage. Looking at it again I don't
see how
thread = threading.currentThread().getName()
try:
self.lock.acquire()
if thread in self.ios:
self.ios[thread].write(data)
else:
t = self.ios[thread] = StringIO()
t.write(data)
finally:
self.lock.release()
isn't using thread local storage in
self.ios[threading.currentThread().getName()]
Agreed with the rest, though while I've used Twisted
some and think I understand the idea of a reactor
based system I still haven't internalized it yet.
Andrew
dalke at dalkescientific.com
More information about the Python-list
mailing list