asyncio KeyboardInterrupt in select

2019-03-27 Thread Thomas Grainger
poll(timeout, max_ev) KeyboardInterrupt ^CError in atexit._run_exitfuncs: Traceback (most recent call last): File "/usr/lib/python3.6/concurrent/futures/thread.py", line 40, in _python_exit t.join() File "/usr/lib/python3.6/threading.py", line 1056, in join self._wait_for_

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
ility of .9 it isn't. The result should be: Mr. Smith bought example. cheapsite. com for 1. 5 million dollars, i. e. he paid a lot for it. Did he mind? Adam Jones Jr. thinks he didn't. In any case, this isn't true... Well, with a probability of . 9 it isn't. #

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

2013-11-19 Thread Jai
e didn't. In any case, this isn't true... Well, with a probability of .9 it isn't. The result should be: Mr. Smith bought example. cheapsite. com for 1. 5 million dollars, i. e. he paid a lot for it. Did he mind? Adam Jones Jr. thinks he didn't. In any case, this isn&

KeyboardInterrupt in Subproccesses

2013-07-19 Thread Matthew Lefavor
All: I am maintaining a program in Python 2 and need to send it a KeyboardInterrupt to close it. Unfortunately, the program is used as a subprocess in a wrapper subprocess, and so I cannot just directly press CTL-C; I have to use a signal. When I run the program "bare" (not in a subp

try/except KeyboardInterrupt vs signal handler for SIGINT

2012-05-07 Thread Rafael Durán Castañeda
Hi, I was wondering which approach is better to stop several servers from just on python application when 'ctrl-c' is pressed, a try/except KeyboardInterrupt or just registering a SIGINT handler and exit when the signal is triggered. Any advantage/disadvantage from one approach

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-09 Thread Paul Kölle
Am 09.05.2010 11:59, schrieb Lawrence D'Oliveiro: In message, exar...@twistedmatrix.com wrote: On 07:48 am, l...@geek-central.gen.new_zealand wrote: In message, exar...@twistedmatrix.com wrote: This is a good example of why it's a bad idea to use select on Windows. Instead, use WaitForMulti

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-09 Thread Lawrence D'Oliveiro
In message , exar...@twistedmatrix.com wrote: > On 07:48 am, l...@geek-central.gen.new_zealand wrote: > >>In message , >>exar...@twistedmatrix.com wrote: >> >>>This is a good example of why it's a bad idea to use select on >>>Windows. >>>Instead, use WaitForMultipleObjects. >> >>How are you suppo

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-08 Thread Giampaolo Rodolà
2010/5/8 Antoine Pitrou : > On Sat, 8 May 2010 13:47:53 +0200 > Giampaolo Rodolà wrote: >> >> Assuming loop() function does something like this: >> >>      ... >>      select.select(r, w, e, timeout) >>      scheduler()  # checks for scheduled calls to be fired >>      ... >> >> ...imagine a case

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-08 Thread exarkun
On 11:47 am, g.rod...@gmail.com wrote: 2010/5/7 Antoine Pitrou : Le Fri, 07 May 2010 21:55:15 +0200, Giampaolo Rodol� a �crit�: Of course, but 30 seconds look a little bit too much to me, also because (I might be wrong here) I noticed that a smaller timeout seems to result in better performan

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-08 Thread exarkun
On 07:48 am, l...@geek-central.gen.new_zealand wrote: In message , exar...@twistedmatrix.com wrote: This is a good example of why it's a bad idea to use select on Windows. Instead, use WaitForMultipleObjects. How are you supposed to write portable code, then? With WaitForMultipleObjects on

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-08 Thread Antoine Pitrou
On Sat, 8 May 2010 13:47:53 +0200 Giampaolo Rodolà wrote: > > Assuming loop() function does something like this: > > ... > select.select(r, w, e, timeout) > scheduler() # checks for scheduled calls to be fired > ... > > ...imagine a case where there's a connection (aka a di

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-08 Thread Giampaolo Rodolà
2010/5/7 Antoine Pitrou : > Le Fri, 07 May 2010 21:55:15 +0200, Giampaolo Rodolà a écrit : >> Of course, but 30 seconds look a little bit too much to me, also because >> (I might be wrong here) I noticed that a smaller timeout seems to result >> in better performances. > > That's probably bogus. P

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-08 Thread Lawrence D'Oliveiro
In message , exar...@twistedmatrix.com wrote: > This is a good example of why it's a bad idea to use select on Windows. > Instead, use WaitForMultipleObjects. How are you supposed to write portable code, then? -- http://mail.python.org/mailman/listinfo/python-list

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-07 Thread exarkun
On 7 May, 07:25 pm, p.f.mo...@gmail.com wrote: On 7 May 2010 15:36, Giampaolo Rodol� wrote: You can easily avoid this by setting a lower timeout when calling asyncore.loop(), like 1 second or less (for example, Twisted uses 0.001 secs). Thanks, that's what I was considering. This is a good

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-07 Thread Antoine Pitrou
Le Fri, 07 May 2010 21:55:15 +0200, Giampaolo Rodolà a écrit : > Of course, but 30 seconds look a little bit too much to me, also because > (I might be wrong here) I noticed that a smaller timeout seems to result > in better performances. That's probably bogus. > Plus, if scheduled callbacks are

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-07 Thread Giampaolo Rodolà
2010/5/7 Antoine Pitrou : > Le Fri, 07 May 2010 16:36:44 +0200, Giampaolo Rodolà a écrit : >> You can easily avoid this by setting a lower timeout when calling >> asyncore.loop(), like 1 second or less (for example, Twisted uses 0.001 >> secs). >> Actually there's no reason for asyncore to have suc

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-07 Thread Paul Moore
On 7 May 2010 15:36, Giampaolo Rodolà wrote: > You can easily avoid this by setting a lower timeout when calling > asyncore.loop(), like 1 second or less (for example, Twisted uses > 0.001 secs). Thanks, that's what I was considering. > Actually there's no reason for asyncore to have such a high

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-07 Thread Antoine Pitrou
Le Fri, 07 May 2010 16:36:44 +0200, Giampaolo Rodolà a écrit : > You can easily avoid this by setting a lower timeout when calling > asyncore.loop(), like 1 second or less (for example, Twisted uses 0.001 > secs). > Actually there's no reason for asyncore to have such a high default > timeout (30 s

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-07 Thread Giampaolo Rodolà
.socket() > select.select([s], [], [], 30) > > and then press Ctrl-C, Python waits for the 30 seconds before raising > KeyboardInterrupt. > > Is this a known limitation on Windows? I see no mention of it in the > documentation. Assuming it is a known limitation, is there a

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-07 Thread Paul Moore
On 6 May, 20:58, Thomas Heller wrote: > If you look at the source code for time.sleep(), which CAN be interrupted > by pressing Ctrl-C, you will find that it is carefully programmed to be > interruptible (sp?).  Which is not the case for select.select(), obviously. Thanks - given this, would it b

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-06 Thread Thomas Heller
Python waits for the 30 seconds before raising > KeyboardInterrupt. > > Is this a known limitation on Windows? I see no mention of it in the > documentation. Assuming it is a known limitation, is there a way round > it? (I'm writing a tiny server using asyncore/asynchat, and

Windows - select.select, timeout and KeyboardInterrupt

2010-05-06 Thread Paul Moore
>From a quick experiment, it seems that select.select with a timeout doesn't react to a keyboard interrupt until the timeout expires. Specifically, if I do s = socket.socket() select.select([s], [], [], 30) and then press Ctrl-C, Python waits for the 30 seconds before raising KeyboardI

KeyboardInterrupt and DiskIO

2010-04-27 Thread Björn Lindqvist
DiskIO appears to not be interruptable. For example: >>> open('bighugefile.sql').read() Pressing Ctrl-C (on Linux with python 2.6.4) will not interrupt the command. I believe that it used to in previous versions of python but I may be mistaken. Is it supposed to be that way? The behavior is annoy

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
running = any(t.is_alive() for t in threads) except KeyboardInterrupt: running = False -- http://mail.python.org/mailman/listinfo/python-list

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 >

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?

Re: KeyboardInterrupt

2009-12-10 Thread mattia
ements 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

2009-12-10 Thread Matthew Barnett
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. Ouch, so the simplest solution is just insert in the 'main' function a try/catch? I believed there was the ne

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 si

Re: KeyboardInterrupt

2009-12-10 Thread mattia
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

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 catchin

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

2009-06-21 Thread Philip Semanchuk
on. For C code, the solution you give sounds like a good one. My only misgiving is that the user might expect to get a KeyboardInterrupt in response to Ctrl-C, so it might be better to just let it propagate instead of turning it into a different exception. I completely agree. The simple solution (

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

2009-06-20 Thread greg
ike a good one. My only misgiving is that the user might expect to get a KeyboardInterrupt in response to Ctrl-C, so it might be better to just let it propagate instead of turning it into a different exception. -- Greg -- http://mail.python.org/mailman/listinfo/python-list

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

2009-06-20 Thread Philip Semanchuk
is KeyboardInterrupt, not the special exception from the IPC module. So I looked in the source code how they did it: The code is in Parser/myreadline.c. This code for input in function calls PyErr_CheckSignals() and PyOS_InterruptOccurred() for a proper handling of the interrupt. So it seems the

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

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. N

KeyboardInterrupt eats my error and then won't be caught

2009-06-18 Thread Philip Semanchuk
signal. However, the caller never sees the error I set. Instead they get a KeyboardInterrupt that refuses to be caught by try/except. Here's a sample program that demonstrates the problem when run from the command line: # --- import posix_ipc

Re: Multi-Threading and KeyboardInterrupt

2009-06-15 Thread Mike Kazantsev
it's time waiting for a separate non-Python subprocess (created > with subprocess.Popen) to finish anyway. (I guess Python would see > this as IO-blocking) Therefore, if you can fix my toy example with > threading, that's fine. > > DB.py, followed by a KeyboardInterr

Re: Multi-Threading and KeyboardInterrupt

2009-06-15 Thread Matt
ted with subprocess.Popen) to finish anyway. (I guess Python would see this as IO-blocking) Therefore, if you can fix my toy example with threading, that's fine. DB.py, followed by a KeyboardInterrupt yields the output in a.out. I want roughly the output in desired.out. What do I need

Re: Multi-Threading and KeyboardInterrupt

2009-06-15 Thread Mike Kazantsev
On Mon, 15 Jun 2009 05:37:14 -0700 (PDT) OdarR wrote: > On 13 juin, 07:25, Mike Kazantsev wrote: > > There was quite interesting explaination of what happens when you send > > ^C with threads, posted on concurrency-sig list recently: > > > >  http://blip.tv/file/2232410 > >  http://www.dabeaz.co

Re: Multi-Threading and KeyboardInterrupt

2009-06-15 Thread OdarR
On 13 juin, 07:25, Mike Kazantsev wrote: > There was quite interesting explaination of what happens when you send > ^C with threads, posted on concurrency-sig list recently: > >  http://blip.tv/file/2232410 >  http://www.dabeaz.com/python/GIL.pdf > > Can be quite shocking, but my experience w/ thr

Off-topic: Usenet archiving history (was Re: FW: [Tutor] Multi-Threading and KeyboardInterrupt)

2009-06-13 Thread Aahz
In article , Dennis Lee Bieber wrote: > > As for the use of X-Noarchive headers... Back before Google, most >NNTP servers had automatic expiration of messages (on my ISP at the >time, the binary groups expired after 24 hours!, most messages expired >after one or two weeks). I never used X-N

Re: Multi-Threading and KeyboardInterrupt

2009-06-13 Thread Mike Kazantsev
On Sat, 13 Jun 2009 04:42:16 -0700 (PDT) koranthala wrote: > Are there other videos/audio like this? I am learning more from these > videos than by experience alone. Indeed, it is a very interesting presentation, but I'm afraid I've stumbled upon it just as you did, but on concurrency-sig mailin

Re: Multi-Threading and KeyboardInterrupt

2009-06-13 Thread koranthala
n will get interrupt. > > > > > > def runAll(): > > >     workers = [ Thread(target = runSingle, args = [i]) > > >             for i in xrange(MAX_SUBPROCS + 1) ] > > >     try: > > >         for w in workers: > > >             w.start() > > >    

Re: [Tutor] Multi-Threading and KeyboardInterrupt

2009-06-12 Thread Mike Kazantsev
surance that any thread other than > the main program will receive a keyboard interrupt. In fact, no thread other than the main will get interrupt. > > def runAll(): > > workers = [ Thread(target = runSingle, args = [i]) > > for i in xrange(MAX_SUBPROCS

Re: FW: [Tutor] Multi-Threading and KeyboardInterrupt

2009-06-11 Thread Graham Dumpleton
On Jun 12, 3:35 pm, Dennis Lee Bieber wrote: > On Thu, 11 Jun 2009 08:44:24 -0500, "Strax-Haber, Matthew (LARC-D320)" > declaimed the following in > gmane.comp.python.general: > > > I sent this to the Tutor mailing list and did not receive a response. > > Perhaps one of you might be able to offer

FW: [Tutor] Multi-Threading and KeyboardInterrupt

2009-06-11 Thread Strax-Haber, Matthew (LARC-D320)
Reply-To: Matthew Strax-Haber > Date: Tue, 9 Jun 2009 22:01:33 -0500 > To: Python Tutor > Subject: [Tutor] Multi-Threading and KeyboardInterrupt > > Hey everyone, > > I hope one of you can help me with this. This is my first foray into > multi-threaded programming. I h

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
er server_forever exited, shutdown() blocks forever. from SocketServer import TCPServer, BaseRequestHandler from threading import Thread server = TCPServer(('localhost',1234), BaseRequestHandler) run_thread = Thread(target=server.serve_forever) run_thread.start() try: print "

Re: KeyboardInterrupt catch does not shut down the socketserver

2009-05-16 Thread Igor Katson
er server = TCPServer(('localhost',1234), BaseRequestHandler) try: server.serve_forever() except KeyboardInterrupt: print "^C detected" pass finally: print "server_close()" server.server_close() print "bye" (I've opened ht

Re: KeyboardInterrupt catch does not shut down the socketserver

2009-05-15 Thread Igor Katson
er server = TCPServer(('localhost',1234), BaseRequestHandler) try: server.serve_forever() except KeyboardInterrupt: print "^C detected" pass finally: print "server_close()" server.server_close() print "bye" (I've opened ht

Re: KeyboardInterrupt catch does not shut down the socketserver

2009-05-15 Thread Gabriel Genellina
7;localhost',1234), BaseRequestHandler) try: server.serve_forever() except KeyboardInterrupt: print "^C detected" pass finally: print "server_close()" server.server_close() print "bye" (I've opened http://bugs.python.org/issue6031 )

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

KeyboardInterrupt catch does not shut down the socketserver

2009-05-15 Thread Igor Katson
I have problems in getting a SocketServer to shutdown. Why does this not actually stop the application? from SocketServer import UnixStreamServer, BaseRequestHandler server = UnixStreamServer('/tmp/ss.sock', BaseRequestHandler) try: server.serve_forever() except Keyboar

Re: How do i : Python Threads + KeyboardInterrupt exception

2008-06-20 Thread Rhamphoryncus
On Jun 19, 11:09 pm, Brendon Costa <[EMAIL PROTECTED]> wrote: > > If only the main thread can receive KeyboardInterrupt, is there any > > reason why you couldn't move the functionality of the Read thread into > > the main thread? It looks like it's not doing any w

Re: How do i : Python Threads + KeyboardInterrupt exception

2008-06-19 Thread Brendon Costa
> If only the main thread can receive KeyboardInterrupt, is there any > reason why you couldn't move the functionality of the Read thread into > the main thread? It looks like it's not doing any work, just waiting > for the Proc thread to finish. > > You could start the

Re: How do i : Python Threads + KeyboardInterrupt exception

2008-06-19 Thread MRAB
t included a > "die" object and "write" to that object to break the blocking wait. > >         If your blocking call has no time-out variant, you may be stuck... > If only the main thread can receive KeyboardInterrupt, is there any reason why you couldn't move the f

Re: How do i : Python Threads + KeyboardInterrupt exception

2008-06-19 Thread Brendon Costa
I tested this a bit more. My windows example was incorrect. It should have used CTRL_C_EVENT. But even then, the problem is that the process will also close the console window from which it was called because of the 0. Also this requires that the process actually have a console and is not a GUI app

Re: How do i : Python Threads + KeyboardInterrupt exception

2008-06-18 Thread Brendon Costa
I tested this a bit more. My windows example was incorrect. It should have used CTRL_C_EVENT. But even then, the problem is that the process will also close the console window from which it was called because of the 0. Also this requires that the process actually have a console and is not a GUI app

Re: How do i : Python Threads + KeyboardInterrupt exception

2008-06-18 Thread Brendon Costa
he > Python C API) to inject a KeyboardInterrupt exception into the Read thread > - but I don't know if it will work at all, the execution might be blocked > waiting for an I/O call to complete, and never return to Python code... > Unfortunately that is the problem. It is blocking in a IO syste

Re: How do i : Python Threads + KeyboardInterrupt exception

2008-06-18 Thread Gabriel Genellina
hat is the standard/best way of implementing such a pattern that works in the presence of errors and particularly with the KeyboardInterrupt exception?" I don't know the "standard" way, but perhaps you can get some ideas from this recent thread: http://groups.google.com/group/com

How do i : Python Threads + KeyboardInterrupt exception

2008-06-18 Thread Brendon Costa
f errors and particularly with the KeyboardInterrupt exception?" Some sample code is shown below. This code works as is, except in the case where the "Proc" thread wants to initiate the exit of the application. For example: * running the code below and pressing Ctrl + C works f

Re: FreeBSD KeyboardInterrupt not captured

2008-05-07 Thread Rhamphoryncus
hread): > def __init__(self): > super(MyThread, self).__init__() > self.start() > > def run(self): > while True: > try: > time.sleep(10) >

FreeBSD KeyboardInterrupt not captured

2008-05-07 Thread radim . marek
t() def run(self): while True: try: time.sleep(10) except KeyboardInterrupt: print 'thread keyboard interrupt' def main(): my = MyThread()

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

KeyboardInterrupt should not kill subprocess

2008-02-21 Thread Michael Goerz
nother dummy program if it isn't p = subprocess.Popen(['sleep', '10']) while True: try: time.sleep(1) pass # normal program procedure print "subprocess poll: " + str(p.poll()) except KeyboardInterrupt:

Re: Catching a non-Exception object (KeyboardInterrupt)

2008-02-04 Thread Gabriel Genellina
En Mon, 04 Feb 2008 11:53:52 -0200, Michael Goerz <[EMAIL PROTECTED]> escribi�: > when I try to catch ctrl+c with > > except KeyboardInterrupt: > > pychecker tells me > > Catching a non-Exception object (KeyboardInterrupt) > > It works fine, but the message i

Re: Catching a non-Exception object (KeyboardInterrupt)

2008-02-04 Thread Duncan Booth
Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > Michael Goerz <[EMAIL PROTECTED]> writes: > >> when I try to catch ctrl+c with >> >> except KeyboardInterrupt: >> >> pychecker tells me >> >> Catching a non-Exception object (KeyboardInterrup

Re: Catching a non-Exception object (KeyboardInterrupt)

2008-02-04 Thread Hrvoje Niksic
Michael Goerz <[EMAIL PROTECTED]> writes: > when I try to catch ctrl+c with > > except KeyboardInterrupt: > > pychecker tells me > > Catching a non-Exception object (KeyboardInterrupt) Looks like a pychecker bug. It might be confused by KeyboardInterrupt being deri

Catching a non-Exception object (KeyboardInterrupt)

2008-02-04 Thread Michael Goerz
Hi, when I try to catch ctrl+c with except KeyboardInterrupt: pychecker tells me Catching a non-Exception object (KeyboardInterrupt) It works fine, but the message indicates that it's not completely clean. How should I write the exception correctly? Thanks, Michael --

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

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

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 "

KeyboardInterrupt not caught

2007-02-16 Thread ruka_at_
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" except: print "caught all" self.showtraceback() pr

Re: KeyboardInterrupt from syscalls

2006-11-22 Thread Fredrik Tolf
I see. So if I get that right, that would mean that if I, in my function, would loop and retry when getting an EINTR instead of returning, a KeyboardInterrupt from e.g. Ctrl-C would be delayed until it has other reason to return? Thanks for your answer! Fredrik Tolf -- http://mail.python.org/mailman/listinfo/python-list

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

KeyboardInterrupt from syscalls

2006-11-22 Thread Fredrik Tolf
Dear List, I was writing a Python extension module, including a sleeping call to poll(2), and noticed, to my great surprise (and joy), that even when blocking there, KeyboardInterrupt still worked properly when sending SIGINTs to the interpreter. It really got me wondering how it works, though

Re: Trace KeyboardInterrupt exception?

2006-06-15 Thread Tony Nelson
In article <[EMAIL PROTECTED]>, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > if you want to interrupt the code to find out where it is, > you can instead connect to it in gdb and get the python traceback of > each thread. > if you're interested I'll post the necesary gdb-macro for that (didn'

Re: Trace KeyboardInterrupt exception?

2006-06-15 Thread [EMAIL PROTECTED]
if you want to interrupt the code to find out where it is, you can instead connect to it in gdb and get the python traceback of each thread. if you're interested I'll post the necesary gdb-macro for that (didn't put it on the net yet) -- http://mail.python.org/mailman/listinfo/python-list

Re: Trace KeyboardInterrupt exception?

2006-06-14 Thread Tony Nelson
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > Tony Nelson wrote: > > I'm trying to find out what is eating some KeyboardInterrupt exceptions > > in a fairly large program (yum). My KeyboardInterrupt handler is called > > for some Ctl-C presses,

Re: Trace KeyboardInterrupt exception?

2006-06-14 Thread andrewdalke
Tony Nelson wrote: > I'm trying to find out what is eating some KeyboardInterrupt exceptions > in a fairly large program (yum). My KeyboardInterrupt handler is called > for some Ctl-C presses, but for others nothing seems to happen. > ... I'd like to use a debugger to tra

Trace KeyboardInterrupt exception?

2006-06-13 Thread Tony Nelson
I'm trying to find out what is eating some KeyboardInterrupt exceptions in a fairly large program (yum). My KeyboardInterrupt handler is called for some Ctl-C presses, but for others nothing seems to happen. Grepping the source (what of it I've found, looking at import statement

Re: exception KeyboardInterrupt and os.system command

2005-11-29 Thread malv
Indeed, I did the experiment again with while 1: y = os.system("sleep 1") print y and it ALWAYS returns 0, with control-c or without. >From past experience, I am pretty sure that in other cases I have been getting non-zero return values. So I would hesitate to believe that what you observe i

Re: exception KeyboardInterrupt and os.system command

2005-11-28 Thread darren kirby
Thanks for the tips everyone, although it turns out this is not a python problem at all. After several tests with mpg123 both direct on the cli, and wrapped in an os.system() call, I see it is _always_ returning 0 exit status whether I interrupt it or not. I went to the mpg123 website to see if

Re: exception KeyboardInterrupt and os.system command

2005-11-28 Thread Donn Cave
In article <[EMAIL PROTECTED]>, "malv" <[EMAIL PROTECTED]> wrote: > That's also kind of what I expected. > However, I quickly tried: > import os > while 1: > y = os.system("sleep 1") > z = (y >> 8) & 0xFF > print z > > I never get anything in return but 0, hitting c-C or not. > I h

Re: exception KeyboardInterrupt and os.system command

2005-11-28 Thread malv
That's also kind of what I expected. However, I quickly tried: import os while 1: y = os.system("sleep 1") z = (y >> 8) & 0xFF print z I never get anything in return but 0, hitting c-C or not. I have uset the above code to get exit code returns in the past though. Would there be any

Re: exception KeyboardInterrupt and os.system command

2005-11-27 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > You can tell by the exit code from system() whether the subprocess > exited due to a signal. Consider this code: > import os > while 1: > print os.system("sleep 1") > unless you happen to hit ctrl-c at the right time, you'll see it print > "2" (and "0" wh

Re: exception KeyboardInterrupt and os.system command

2005-11-27 Thread jepler
You can tell by the exit code from system() whether the subprocess exited due to a signal. Consider this code: import os while 1: print os.system("sleep 1") unless you happen to hit ctrl-c at the right time, you'll see it print "2" (and "0" when the sleep finishes). The exit code

Re: exception KeyboardInterrupt and os.system command

2005-11-27 Thread Diez B. Roggisch
d exit (somewhat) gracefully if the > user decides to abort the program. I am using os.system for the system call, > and I have wrapped the entire main loop in a try: except KeyboardInterrupt > statement to try to attain these ends. > > As it is though, if the program is curren

exception KeyboardInterrupt and os.system command

2005-11-27 Thread darren kirby
abort the program. I am using os.system for the system call, and I have wrapped the entire main loop in a try: except KeyboardInterrupt statement to try to attain these ends. As it is though, if the program is currently in the system command, only that system command is terminated, and the next

Re: KeyboardInterrupt vs extension written in C

2005-10-22 Thread Jp Calderone
except the fact >> that if, for example, I start computing the diameter of a random graph >> of ~10 nodes and ~20 edges, I can't cancel it, because the >> KeyboardInterrupt is not propagated to the Python toplevel (or it isn't >> even generated until the igraph li

  1   2   >