Re: except block isn't catching exception

2015-08-08 Thread Cameron Simpson
On 08Aug2015 18:17, Chris Angelico wrote: On Sat, Aug 8, 2015 at 6:11 PM, Cameron Simpson wrote: From: https://docs.python.org/3/library/signal.html#execution-of-python-signal-handlers we have: A Python signal handler does not get executed inside the low-level (C) signal handler. Instead

Re: except block isn't catching exception

2015-08-08 Thread Chris Angelico
On Sat, Aug 8, 2015 at 6:11 PM, Cameron Simpson wrote: > From: > > > https://docs.python.org/3/library/signal.html#execution-of-python-signal-handlers > > we have: > > A Python signal handler does not get executed inside the low-level (C) > signal handler. Instead, the low-level signal handler s

Re: except block isn't catching exception

2015-08-08 Thread Cameron Simpson
On 08Aug2015 17:08, Chris Angelico wrote: On Sat, Aug 8, 2015 at 4:56 PM, Ian Kelly wrote: On Fri, Aug 7, 2015 at 8:44 PM, Chris Angelico wrote: The exception isn't happening inside sock.accept(), as I explained. So you can't catch it there. Where does the exception happen then? Your expla

Re: except block isn't catching exception

2015-08-08 Thread Chris Angelico
On Sat, Aug 8, 2015 at 4:56 PM, Ian Kelly wrote: > On Fri, Aug 7, 2015 at 8:44 PM, Chris Angelico wrote: >> The exception isn't happening inside sock.accept(), as I explained. So >> you can't catch it there. > > Where does the exception happen then? Your explanation only covered > why the blockin

Re: except block isn't catching exception

2015-08-07 Thread Ian Kelly
On Fri, Aug 7, 2015 at 8:44 PM, Chris Angelico wrote: > The exception isn't happening inside sock.accept(), as I explained. So > you can't catch it there. Where does the exception happen then? Your explanation only covered why the blocking call cannot be interrupted by it, not why the exception i

Re: except block isn't catching exception

2015-08-07 Thread Chris Angelico
On Sat, Aug 8, 2015 at 3:16 AM, 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 'Keyb

Re: except block isn't catching exception

2015-08-07 Thread sohcahtoa82
On Thursday, August 6, 2015 at 5:46:19 PM UTC-7, Chris Angelico wrote: > On Fri, Aug 7, 2015 at 10:34 AM, wrote: > > Despite my "except KeyboardInterrupt", the KeyboardInterrupt forced by the > > thread.interrupt_main() in the worker thread isn't being caught. > > > > Other things worth noting i

Re: except block isn't catching exception

2015-08-06 Thread Chris Angelico
On Fri, Aug 7, 2015 at 10:34 AM, wrote: > Despite my "except KeyboardInterrupt", the KeyboardInterrupt forced by the > thread.interrupt_main() in the worker thread isn't being caught. > > Other things worth noting is that the exception takes about 3 seconds after > the call to thread.interrupt_

except block isn't catching exception

2015-08-06 Thread sohcahtoa82
I've run into strange behavior involving a blocking call to a socket accept() on the main thread and thread.interrupt_main() being called on a worker thread. Here's my code: # BEGIN exception_test.py import socket import thread import threading import time def worker(): time.sleep(2)