Re: KeyboardInterrupt close failed in file object destructor: sys.excepthook is missing lost sys.stderr

2013-11-19 Thread Neil Cerutti
MOn Tue, Nov 19, 2013 at 10:35 AM, Jai wrote: > please help what is this i have try lot but unable to remove it Your code is getting into an infinite loop. One problem is, I suspect: > def find_position(line): > pun = "" > if re.search(r"[.?!]+", line): > pun = re.search(r"[.?!]

Re: KeyboardInterrupt close failed in file object destructor: sys.excepthook is missing lost sys.stderr

2013-11-19 Thread Mark Lawrence
On 19/11/2013 15:35, Jai wrote: Code # #!/usr/bin/env python import sys, re def find_position(line): pun = "" if re.search(r"[.?!]+", line): pun = re.search(r"[.?!]+", line).group() pos = line.find(pun) pos = pos+len(pun)-1 retu

Re: KeyboardInterrupt

2009-12-10 Thread Gabriel Genellina
En Thu, 10 Dec 2009 20:43:48 -0300, mattia escribió: Il Thu, 10 Dec 2009 23:10:02 +, Matthew Barnett ha scritto: Only the main thread can receive the keyboard interrupt. Ok, so is there any way to stop all the threads if the keyboard interrupt is received? If all other threads (except

Re: KeyboardInterrupt

2009-12-10 Thread Lie Ryan
On 12/11/2009 10:43 AM, mattia wrote: Ok, so is there any way to stop all the threads if the keyboard interrupt is received? You can't stop a thread from outside. The thread has to end itself (by ending the function). Usually, in the thread, you will check the value of a variable. If it's fal

Re: KeyboardInterrupt

2009-12-10 Thread mattia
Il Wed, 09 Dec 2009 16:19:24 -0800, Jon Clements ha scritto: > On Dec 9, 11:53 pm, mattia wrote: >> Hi all, can you provide me a simple code snippet to interrupt the >> execution of my program catching the KeyboardInterrupt signal? >> >> Thanks, >> Mattia > > Errr, normally you can just catch th

Re: KeyboardInterrupt

2009-12-10 Thread Jon Clements
On Dec 9, 11:53 pm, mattia wrote: > Hi all, can you provide me a simple code snippet to interrupt the > execution of my program catching the KeyboardInterrupt signal? > > Thanks, > Mattia Errr, normally you can just catch the KeyboardInterrupt exception -- is that what you mean? Jon. -- http://

Re: KeyboardInterrupt

2009-12-10 Thread mattia
Il Thu, 10 Dec 2009 23:10:02 +, Matthew Barnett ha scritto: > mattia wrote: >> Il Thu, 10 Dec 2009 04:56:33 +, Brad Harms ha scritto: >> >>> On Thu, 10 Dec 2009 00:29:45 +, mattia wrote: >>> Il Wed, 09 Dec 2009 16:19:24 -0800, Jon Clements ha scritto: > On Dec 9, 11:53 p

Re: KeyboardInterrupt

2009-12-10 Thread Matthew Barnett
mattia wrote: Il Thu, 10 Dec 2009 04:56:33 +, Brad Harms ha scritto: On Thu, 10 Dec 2009 00:29:45 +, mattia wrote: Il Wed, 09 Dec 2009 16:19:24 -0800, Jon Clements ha scritto: On Dec 9, 11:53 pm, mattia wrote: Hi all, can you provide me a simple code snippet to interrupt the execu

Re: KeyboardInterrupt

2009-12-10 Thread Daniel Stutzbach
On Thu, Dec 10, 2009 at 4:42 PM, mattia wrote: > def go(): >threads = [Thread(target=do_work, args=()) for _ in range(2)] >for t in threads: >t.start() >for t in threads: >t.join() > The KeyboardInterrupt goes to the main thread, which is sitting there in t.join() wit

Re: KeyboardInterrupt

2009-12-10 Thread mattia
Il Thu, 10 Dec 2009 04:56:33 +, Brad Harms ha scritto: > On Thu, 10 Dec 2009 00:29:45 +, mattia wrote: > >> Il Wed, 09 Dec 2009 16:19:24 -0800, Jon Clements ha scritto: >> >>> On Dec 9, 11:53 pm, mattia wrote: Hi all, can you provide me a simple code snippet to interrupt the e

Re: KeyboardInterrupt

2009-12-09 Thread Brad Harms
On Thu, 10 Dec 2009 00:29:45 +, mattia wrote: > Il Wed, 09 Dec 2009 16:19:24 -0800, Jon Clements ha scritto: > >> On Dec 9, 11:53 pm, mattia wrote: >>> Hi all, can you provide me a simple code snippet to interrupt the >>> execution of my program catching the KeyboardInterrupt signal? >>> >>>

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 co

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 o

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 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 IPC

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

2009-06-20 Thread Piet van Oostrum
> greg (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 wa

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 wh

Re: KeyboardInterrupt catch does not shut down the socketserver

2009-05-17 Thread Igor Katson
Gabriel Genellina wrote: En Sat, 16 May 2009 04:04:03 -0300, Igor Katson escribió: Gabriel Genellina wrote: En Fri, 15 May 2009 09:04:05 -0300, Igor Katson escribió: Lawrence D'Oliveiro wrote: In message , Igor Katson wrote: Lawrence D'Oliveiro wrote: In message , Igor Katson wrote: I h

Re: KeyboardInterrupt catch does not shut down the socketserver

2009-05-16 Thread Gabriel Genellina
En Sat, 16 May 2009 04:04:03 -0300, Igor Katson escribió: Gabriel Genellina wrote: En Fri, 15 May 2009 09:04:05 -0300, Igor Katson escribió: Lawrence D'Oliveiro wrote: In message , Igor Katson wrote: Lawrence D'Oliveiro wrote: In message , Igor Katson wrote: I have problems in getting

Re: KeyboardInterrupt catch does not shut down the socketserver

2009-05-16 Thread Igor Katson
Gabriel Genellina wrote: En Fri, 15 May 2009 09:04:05 -0300, Igor Katson escribió: Lawrence D'Oliveiro wrote: In message , Igor Katson wrote: Lawrence D'Oliveiro wrote: In message , Igor Katson wrote: I have problems in getting a SocketServer to shutdown. Do you want to do a shutdown or

Re: KeyboardInterrupt catch does not shut down the socketserver

2009-05-15 Thread Igor Katson
Gabriel Genellina wrote: En Fri, 15 May 2009 09:04:05 -0300, Igor Katson escribió: Lawrence D'Oliveiro wrote: In message , Igor Katson wrote: Lawrence D'Oliveiro wrote: In message , Igor Katson wrote: I have problems in getting a SocketServer to shutdown. Do you want to do a shutdown or

Re: KeyboardInterrupt catch does not shut down the socketserver

2009-05-15 Thread Gabriel Genellina
En Fri, 15 May 2009 09:04:05 -0300, Igor Katson escribió: Lawrence D'Oliveiro wrote: In message , Igor Katson wrote: Lawrence D'Oliveiro wrote: In message , Igor Katson wrote: I have problems in getting a SocketServer to shutdown. Do you want to do a shutdown or a close? I want the se

Re: KeyboardInterrupt catch does not shut down the socketserver

2009-05-15 Thread Igor Katson
Lawrence D'Oliveiro wrote: In message , Igor Katson wrote: Lawrence D'Oliveiro wrote: In message , Igor Katson wrote: I have problems in getting a SocketServer to shutdown. Do you want to do a shutdown or a close? I want the server close the socket ...

Re: KeyboardInterrupt catch does not shut down the socketserver

2009-05-15 Thread Lawrence D'Oliveiro
In message , Igor Katson wrote: > Lawrence D'Oliveiro wrote: > >> In message , Igor >> Katson wrote: >> >>> I have problems in getting a SocketServer to shutdown. >> >> Do you want to do a shutdown or a close? >> > I want the server close the socket ... You want to do a close, do a close,

Re: KeyboardInterrupt catch does not shut down the socketserver

2009-05-15 Thread Igor Katson
Lawrence D'Oliveiro wrote: In message , Igor Katson wrote: I have problems in getting a SocketServer to shutdown. Do you want to do a shutdown or a close? I want the server close the socket, and the program to continue after that (in this case, just to terminate). -- http://mai

Re: KeyboardInterrupt catch does not shut down the socketserver

2009-05-15 Thread Lawrence D'Oliveiro
In message , Igor Katson wrote: > I have problems in getting a SocketServer to shutdown. Do you want to do a shutdown or a close? -- http://mail.python.org/mailman/listinfo/python-list

Re: KeyboardInterrupt should not kill subprocess

2008-02-21 Thread Donn Cave
In article <[EMAIL PROTECTED]>, Michael Goerz <[EMAIL PROTECTED]> wrote: > But as it seems, a keyboard interrupt will automatically pass down to > the subprocesses, causing them to abort. Is there a way that I can > prevent the subprocesses from being canceled by a keyboard interrupt? You mi

Re: KeyboardInterrupt not caught

2007-02-16 Thread ruka_at_
On 16 Feb., 12:16, [EMAIL PROTECTED] wrote: > On 16 Feb., 11:44, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > > I've tried it in cygwin, result: $ python.exe c:/work/py_src/ctrl_test.py kbd-interr,SystemExit normal end br Rudi -- http://mail.python.org/mailman/listinfo/python-list

Re: KeyboardInterrupt not caught

2007-02-16 Thread ruka_at_
On 16 Feb., 11:44, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: Thanks to all of you, for the fast answers. The code I showed you is actually the code running. I tried to catch eof, cause I read ^C could produce EOF (the self.showtraceback() was just a stupid cut 'n paste). But not even the exce

Re: KeyboardInterrupt not caught

2007-02-16 Thread Gabriel Genellina
En Fri, 16 Feb 2007 07:26:09 -0300, Steven D'Aprano <[EMAIL PROTECTED]> escribió: > I seem to have a vague recollection that the keyboard interrupt under > Windows isn't ^C but something else... ^Z maybe? Ctrl-C is the keyboard interrupt, Ctrl-Z means EOF. -- Gabriel Genellina -- http://mai

Re: KeyboardInterrupt not caught

2007-02-16 Thread Steven D'Aprano
On Fri, 16 Feb 2007 01:47:43 -0800, ruka_at_ wrote: > Hi, > why is KeyboardInterrupt not caught (xp)? > import sys > try: > inp = sys.stdin.read() > except (KeyboardInterrupt, SystemExit): > print "kbd-interr,SystemExit" > except EOFError: > print "eof encountered" I don't think you e

Re: KeyboardInterrupt not caught

2007-02-16 Thread Gabriel Genellina
En Fri, 16 Feb 2007 06:58:54 -0300, Daniel Nogradi <[EMAIL PROTECTED]> escribió: >> why is KeyboardInterrupt not caught (xp)? > > Hi, are you sure this is exactly what you run? > The code above works perfectly for me and prints > > kbd-interr,SystemExit > normal end > > as it should upon pressin

Re: KeyboardInterrupt not caught

2007-02-16 Thread Daniel Nogradi
> why is KeyboardInterrupt not caught (xp)? > import sys > try: > inp = sys.stdin.read() > except (KeyboardInterrupt, SystemExit): > print "kbd-interr,SystemExit" > except EOFError: > print "eof encountered" > except: > print "caught all" > self.showtraceback() > print "normal e

Re: KeyboardInterrupt from syscalls

2006-11-22 Thread Fredrik Tolf
On Wed, 2006-11-22 at 19:45 +0100, Fredrik Lundh wrote: > Fredrik Tolf wrote: > > > So how does it work? Does my code get to return Py_FALSE, and the > > interpreter ignores it, seeing that an exception is set? Is a non-local > > exit performed right over my call stack (in which case my next quest

Re: KeyboardInterrupt from syscalls

2006-11-22 Thread Fredrik Lundh
Fredrik Tolf wrote: > So how does it work? Does my code get to return Py_FALSE, and the > interpreter ignores it, seeing that an exception is set? Is a non-local > exit performed right over my call stack (in which case my next question > would be how to clean up resources being used from my C code

Re: KeyboardInterrupt vs extension written in C

2005-10-22 Thread Jp Calderone
On 22 Oct 2005 22:02:46 +0200, Dieter Maurer <[EMAIL PROTECTED]> wrote: >"Tamas Nepusz" <[EMAIL PROTECTED]> writes on 20 Oct 2005 15:39:54 -0700: >> The library I'm working on >> is designed for performing calculations on large-scale graphs (~1 >> nodes and edges). I want to create a Python int

Re: KeyboardInterrupt vs extension written in C

2005-10-22 Thread Dieter Maurer
"Tamas Nepusz" <[EMAIL PROTECTED]> writes on 20 Oct 2005 15:39:54 -0700: > The library I'm working on > is designed for performing calculations on large-scale graphs (~1 > nodes and edges). I want to create a Python interface for that library, > so what I want to accomplish is that I could just

Re: KeyboardInterrupt vs extension written in C

2005-10-20 Thread Donn Cave
Quoth "Tamas Nepusz" <[EMAIL PROTECTED]>: | No, that's actually a bit more complicated. The library I'm working on | is designed for performing calculations on large-scale graphs (~1 | nodes and edges). I want to create a Python interface for that library, | so what I want to accomplish is that

Re: KeyboardInterrupt vs extension written in C

2005-10-20 Thread Tamas Nepusz
No, that's actually a bit more complicated. The library I'm working on is designed for performing calculations on large-scale graphs (~1 nodes and edges). I want to create a Python interface for that library, so what I want to accomplish is that I could just type "from igraph import *" in a Pyt

Re: KeyboardInterrupt vs extension written in C

2005-10-20 Thread Diez B. Roggisch
Tamas Nepusz wrote: > Hi everyone, > > I have tried to do some googling before asking my question here, but I > haven't found any suitable answer. I am developing a Python API for a > graph library written in pure C. The library is doing an awful lot of > math computations, and some of them can ta

Re: KeyboardInterrupt being lost?

2005-10-14 Thread David Wahler
Operation Latte Thunder wrote: > I have a simple test proggie that isn't behaving like I expect ( found > below ). The script will infinitely run ( as expected ), but seems to > completely ignore control-C's. Shouldn't the interpreter pass along > KeyboardInterrupts and break out of the while loo