Merge lp:~gary/lazr.smtptest/threadsafety into lp:lazr.smtptest
Status: | Merged |
---|---|
Merged at revision: | 63 |
Proposed branch: | lp:~gary/lazr.smtptest/threadsafety |
Merge into: | lp:lazr.smtptest |
Diff against target: |
103 lines (+37/-6) 3 files modified
src/lazr/smtptest/NEWS.txt (+11/-0) src/lazr/smtptest/server.py (+25/-5) src/lazr/smtptest/version.txt (+1/-1) |
To merge this branch: | bzr merge lp:~gary/lazr.smtptest/threadsafety |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Barry Warsaw | Approve | ||
Review via email: mp+67090@code.launchpad.net |
Description of the change
Hi Barry. As we discussed, these changes make lazr.smtptest more thread-safe for other users of asyncore (such as Launchpad). I am hopeful that this will reduce spurious test failures in tests run in Launchpad's appserver layer. It seems to do the trick for the particular problem that I was trying to diagnose and solve (though the intermittent and opaque nature of these sorts of things means I only have statistics, not absolute confidence).
The addition of add_channel for the server and the channel are to work around the fact that the smtpd base classes (in Python 2.6 and 2.7) do not expose the asyncore map argument to the __init__. The options I saw were to copy over the __init__ code of the two classes, which seemed unattractive; or to try and come up with a hack that involved less code copying while trying to be as un-ugly as possible. add_channel is one of the few methods in the asyncore dispatcher that actually use the mapping, and the first one in the dispatcher's lifecycle to do so, so it seems a relatively reasonable an safe place to do the work, given the unfortunate circumstances. Other ideas welcome.
The other change I made was to actually close the sockets when the server is told to stop: before, we simply cleared out the map, without actually closing the sockets.
I still need to run the LP tests with these changes; I'm more suspicious of the second, smaller change causing a problem to LP than the first.
Thank you!
Gary
All LP tests pass with this branch.