Figure out what to do about zope.sendmail incompatibility with Python >= 2.5.1
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
| Launchpad itself |
High
|
Gary Poster | ||
| zope.sendmail |
Low
|
Gary Poster |
Bug Description
After changes to the design of Python threading in 2.5.1, zope.sendmail.
Workaround: http://
Need to liase with upstream and figure out what on earth to do here.
Changed in launchpad-foundations: | |
importance: | Undecided → High |
milestone: | none → 3.0 |
status: | New → Triaged |
Gary Poster (gary) wrote : | #1 |
Max Bowsher (maxb) wrote : | #2 |
I have not yet.
I should probably write up a fuller description of the problem, and some test programs.
Max Bowsher (maxb) wrote : | #3 |
Description of the situation:
Prior to Python 2.5.1, the atexit handlers were executed when the *main* thread exits. However, http://
For this reason, the shutdown procedure was modified in Python 2.5.1 - now, when the main thread exits, it first makes a private call to threading.
Herein lies the problem. zope.sendmail.
Potential solutions:
(1) To gain behaviour most similar to earlier Python versions, an evil monkeypatch into Python internals like this: http://
(2) Make the QueueProcessorT
I will attach a small Python demo program useful for illustrating and exploring the issue.
Max Bowsher (maxb) wrote : | #4 |
Gary Poster (gary) wrote : | #5 |
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.
affects: | zope3 → zope.sendmail |
Changed in zope.sendmail: | |
status: | New → In Progress |
Changed in launchpad-foundations: | |
status: | Triaged → In Progress |
Changed in zope.sendmail: | |
importance: | Undecided → Low |
assignee: | nobody → Gary Poster (gary) |
Changed in launchpad-foundations: | |
assignee: | nobody → Gary Poster (gary) |
Changed in launchpad-foundations: | |
status: | In Progress → Fix Committed |
Changed in zope.sendmail: | |
status: | In Progress → Fix Released |
Changed in launchpad-foundations: | |
status: | Fix Committed → Fix Released |
Max, have you asked upstream about this, or shall I?