tests/dummysmtpd.py
changeset 35776 75bae69747f0
parent 30559 d83ca854fa21
child 36566 ed96d1116302
--- a/tests/dummysmtpd.py	Sun Jan 21 15:39:48 2018 +0100
+++ b/tests/dummysmtpd.py	Mon Jan 22 00:39:42 2018 -0500
@@ -9,6 +9,7 @@
 import smtpd
 import ssl
 import sys
+import traceback
 
 from mercurial import (
     server,
@@ -27,6 +28,15 @@
     def process_message(self, peer, mailfrom, rcpttos, data):
         log('%s from=%s to=%s\n' % (peer[0], mailfrom, ', '.join(rcpttos)))
 
+    def handle_error(self):
+        # On Windows, a bad SSL connection sometimes generates a WSAECONNRESET.
+        # The default handler will shutdown this server, and then both the
+        # current connection and subsequent ones fail on the client side with
+        # "No connection could be made because the target machine actively
+        # refused it".  If we eat the error, then the client properly aborts in
+        # the expected way, and the server is available for subsequent requests.
+        traceback.print_exc()
+
 class dummysmtpsecureserver(dummysmtpserver):
     def __init__(self, localaddr, certfile):
         dummysmtpserver.__init__(self, localaddr)