On Sat, Aug 8, 2015 at 3:16 AM, <sohcahto...@gmail.com> wrote: > > Though I still doesn't understand why the exception isn't caught when I'm > explicitly trying to catch it. I even tried changing the try/except block to > this: > > try: > connection, _ = sock.accept() > except KeyboardInterrupt: > print 'KeyboardInterrupt caught!' > except socket.timeout: > print 'Socket timeout caught!' > except: > print 'other exception caught!' > finally: > print 'finally!' > > The result prints: > > Interrupting main > main interrupted! > finally!
The exception isn't happening inside sock.accept(), as I explained. So you can't catch it there. ChrisA -- https://mail.python.org/mailman/listinfo/python-list