This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author giampaolo.rodola
Recipients cmcginty, ggenellina, giampaolo.rodola, r.david.murray
Date 2010-06-30.11:38:57
SpamBayes Score 2.2984026e-05
Marked as misclassified No
Message-id <1277897939.91.0.257186131364.issue6589@psf.upfronthosting.co.za>
In-reply-to
Content
Although the use case is pretty uncommon and somewhat twisted (take a look at Lib/test/test_ftplib.py for a nicer approach on wrapping asyncore.loop() in a thread) it is true that if SMTPServer class raise an exception at instantiation time, some garbage remains in asyncore.

To replicate this problem there's no need to involve threads:

>>> import asyncore, smtpd
>>> s = smtpd.SMTPServer(('127.0.0.1', "xxx"),None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.5/smtpd.py", line 280, in __init__
    self.bind(localaddr)
  File "/usr/local/lib/python2.5/asyncore.py", line 303, in bind
    return self.socket.bind(addr)
  File "<string>", line 1, in bind
TypeError: an integer is required
>>> asyncore.socket_map
{3: <smtpd.SMTPServer ('127.0.0.1', 'xxx') at 0xb783528c>}
>>> 

I think it's ok for SMTPServer.__init__ to cleanup asyncore and finally raise the exception, as you suggested in the first place.
I'll provide a patch later today.
History
Date User Action Args
2010-06-30 11:39:00giampaolo.rodolasetrecipients: + giampaolo.rodola, ggenellina, r.david.murray, cmcginty
2010-06-30 11:38:59giampaolo.rodolasetmessageid: <1277897939.91.0.257186131364.issue6589@psf.upfronthosting.co.za>
2010-06-30 11:38:58giampaolo.rodolalinkissue6589 messages
2010-06-30 11:38:57giampaolo.rodolacreate