[Python-Dev] thread safe SMTP module

Jon Ribbens jon+python-dev at unequivocal.co.uk
Wed Mar 14 19:40:04 CET 2007

Aahz <aahz at pythoncraft.com> wrote:
> One small wrinkle (and the reason I suggested bringing this to
> python-dev): I suspect that the problem is not a bug, but simply the
> occasional failure of sockets.  When that happens in a threaded app
> without timeouts, eventually threads "die" (block forever).  But you
> apparently can't use timeouts with file-wrapped sockets, so if that's the
> problem, we need to pick one of:
> * switch to non-wrapped sockets 
> * switch to non-blocking I/O for smtplib
> * make file-wrapped sockets work with timeouts

In case it's helpful, I've put the file-like-sockets-with-timeouts
code that I wrote up here:


This is a pure-Python implementation that provides a file-like
interface to a socket, with timeouts, that definitely works with
threaded programs.

Note it was written in 2002, so any part of the Python 'file'
interface which was added since then is not in there.

More information about the Python-Dev mailing list