tholzer added the comment:

And a test case for smtplib:

import threading
import signal
import os
import smtplib

def go():
    running = True
    pid = os.getpid()

    def killer():
        while running: 
            os.kill(pid, signal.SIGINT)

    signal.signal(signal.SIGINT, lambda x,y: None)
    thread = threading.Thread(target=killer)
    thread.start()

    while 1:
        try:
            smtplib.SMTP('localhost')
        except Exception, ex:
            running = False
            raise
        
if __name__ == '__main__':
    go()

Fails with:

socket.error: [Errno 4] Interrupted system call

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue20611>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to