#!/usr/bin/env python import smtpd import asyncore import threading import time # enable logging asyncore.dispatcher.ignore_log_types = [] class SmtpThread( threading.Thread ): def run(self): s = smtpd.SMTPServer(('127.0.0.1',9999),None) while True: asyncore.loop( timeout=1, count=1 ) # start first SMTP process t1 = SmtpThread() t1.start() print 'started 1st thread' time.sleep(1) # attmpt to run second instance, does not fail gracefully s = smtpd.SMTPServer(('127.0.0.1',9999),None)