Re: KeyboardInterrupt eats my error and then won't be caught

2009-06-21 Thread Philip Semanchuk
On Jun 20, 2009, at 10:21 PM, greg wrote: Philip Semanchuk wrote: Best of all, PyErr_CheckSignals() doesn't interfere with a Python- level signal handler if one is set. Ah, I hadn't realised that you were doing this in C code, and I was trying to think of a Python-level solution. For C

Re: KeyboardInterrupt eats my error and then won't be caught

2009-06-20 Thread Piet van Oostrum
greg g...@cosc.canterbury.ac.nz (g) wrote: g Philip Semanchuk wrote: try: sem.acquire() # User hits Ctrl + C while this is waiting except: print * I caught it! Instead a KeyboardInterrupt error is propagated up to the interpreter and the process is killed as if the try/except

Re: KeyboardInterrupt eats my error and then won't be caught

2009-06-20 Thread Piet van Oostrum
After my previous experiment I was curious how this works with input(). I replaced the sem.acquire() with raw_input() and ran the same tests. Now the inner exception is really taken so it works like the OP expected. The exception, however is KeyboardInterrupt, not the special exception from the

Re: KeyboardInterrupt eats my error and then won't be caught

2009-06-20 Thread Philip Semanchuk
On Jun 20, 2009, at 7:41 AM, Piet van Oostrum wrote: After my previous experiment I was curious how this works with input(). I replaced the sem.acquire() with raw_input() and ran the same tests. Now the inner exception is really taken so it works like the OP expected. The exception, however

Re: KeyboardInterrupt eats my error and then won't be caught

2009-06-20 Thread greg
Philip Semanchuk wrote: Best of all, PyErr_CheckSignals() doesn't interfere with a Python- level signal handler if one is set. Ah, I hadn't realised that you were doing this in C code, and I was trying to think of a Python-level solution. For C code, the solution you give sounds like a good

Re: KeyboardInterrupt eats my error and then won't be caught

2009-06-19 Thread greg
Philip Semanchuk wrote: try: sem.acquire() # User hits Ctrl + C while this is waiting except: print * I caught it! Instead a KeyboardInterrupt error is propagated up to the interpreter and the process is killed as if the try/except wasn't there at all. Not sure exactly

KeyboardInterrupt eats my error and then won't be caught

2009-06-18 Thread Philip Semanchuk
Hi all, I need help understanding how Python deals with Ctrl-C. A user has reported a bug in my posix_ipc module. When a Python app is waiting to acquire an IPC semaphore and the user hits Ctrl-C, my code should return a custom error indicating that the semaphore wait was interrupted by a