diff options
author | Giampaolo RodolĂ <g.rodola@gmail.com> | 2010-06-30 17:50:20 (GMT) |
---|---|---|
committer | Giampaolo RodolĂ <g.rodola@gmail.com> | 2010-06-30 17:50:20 (GMT) |
commit | d68ed93824d20bf50ad5eddca3958d92978ced4a (patch) | |
tree | 7cfb04f898d8360422750416890b062a3693f053 /Lib | |
parent | bf9f79b185719e1471d03983e40a88f49d6e0ffc (diff) | |
download | cpython-d68ed93824d20bf50ad5eddca3958d92978ced4a.zip cpython-d68ed93824d20bf50ad5eddca3958d92978ced4a.tar.gz cpython-d68ed93824d20bf50ad5eddca3958d92978ced4a.tar.bz2 |
Merged revisions 82407 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r82407 | giampaolo.rodola | 2010-06-30 19:47:39 +0200 (mer, 30 giu 2010) | 9 lines
Merged revisions 82404 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82404 | giampaolo.rodola | 2010-06-30 19:38:28 +0200 (mer, 30 giu 2010) | 1 line
fix issue #6589: cleanup asyncore.socket_map if smtpd.SMTPServer constructor raises an exception
........
................
Diffstat (limited to 'Lib')
-rwxr-xr-x | Lib/smtpd.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/Lib/smtpd.py b/Lib/smtpd.py index 3dc9793..76df673 100755 --- a/Lib/smtpd.py +++ b/Lib/smtpd.py @@ -274,14 +274,19 @@ class SMTPServer(asyncore.dispatcher): self._localaddr = localaddr self._remoteaddr = remoteaddr asyncore.dispatcher.__init__(self) - self.create_socket(socket.AF_INET, socket.SOCK_STREAM) - # try to re-use a server port if possible - self.set_reuse_addr() - self.bind(localaddr) - self.listen(5) - print('%s started at %s\n\tLocal addr: %s\n\tRemote addr:%s' % ( - self.__class__.__name__, time.ctime(time.time()), - localaddr, remoteaddr), file=DEBUGSTREAM) + try: + self.create_socket(socket.AF_INET, socket.SOCK_STREAM) + # try to re-use a server port if possible + self.set_reuse_addr() + self.bind(localaddr) + self.listen(5) + except: + self.close() + raise + else: + print('%s started at %s\n\tLocal addr: %s\n\tRemote addr:%s' % ( + self.__class__.__name__, time.ctime(time.time()), + localaddr, remoteaddr), file=DEBUGSTREAM) def handle_accept(self): conn, addr = self.accept() |