Comment 5 for bug 413335

Revision history for this message
Gary Poster (gary) wrote :

This patch works from Max's experiments to use the setDaemon approach. This seems like the right basic idea--really, the current zope.sendmail code is essentially acting like a daemon thread, with the combination of atexit and the _stopped flag simply trying to make the loop's block run as a unit before the thread can exit.

Therefore, I made the thread a daemon. Reviewing the code, it seemed the only point at which the code would not fail cleanly was after the mail was sent and before the msg was removed--a single block of actions. Therefore, as I described in the comment, I tried to tie those two actions together with a lock.

When the atexit code has to wait for the lock, the process no longer dies for some reason: the daemon flag is no longer honored in that case. Therefore, I continue to use the _stopped flag for communication in that case. The _stopped flag is set before the lock is acquired.

I also changed __stopped to _stopped because I generally don't like the Python mangled name game.

Marius Gedminas and Max have both reviewed this patch. I may try to get Francis Lacoste to also review, I'll verify it works in Launchpad, and then I plan to push it upstream and make a release today or tomorrow. I intend to make it a bugfix release of zope.sendmail: 3.5.2.