except block isn't catching exception
rosuav at gmail.com
Sat Aug 8 04:44:31 CEST 2015
On Sat, Aug 8, 2015 at 3:16 AM, <sohcahtoa82 at 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:
> connection, _ = sock.accept()
> except KeyboardInterrupt:
> print 'KeyboardInterrupt caught!'
> except socket.timeout:
> print 'Socket timeout caught!'
> print 'other exception caught!'
> print 'finally!'
> The result prints:
> Interrupting main
> main interrupted!
The exception isn't happening inside sock.accept(), as I explained. So
you can't catch it there.
More information about the Python-list