##// END OF EJS Templates
Install signal handler on each code run to protect against user code that...
fperez -
Show More
@@ -4,7 +4,7 b''
4 All the matplotlib support code was co-developed with John Hunter,
4 All the matplotlib support code was co-developed with John Hunter,
5 matplotlib's author.
5 matplotlib's author.
6
6
7 $Id: Shell.py 2221 2007-04-06 02:58:37Z fperez $"""
7 $Id: Shell.py 2222 2007-04-06 17:11:27Z fperez $"""
8
8
9 #*****************************************************************************
9 #*****************************************************************************
10 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
10 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
@@ -340,9 +340,6 b' class MTInteractiveShell(InteractiveShell):'
340 # enough, because uses like macros cause reentrancy.
340 # enough, because uses like macros cause reentrancy.
341 self.code_queue = Queue.Queue()
341 self.code_queue = Queue.Queue()
342
342
343 # Track once we properly install our special sigint handler
344 self._sigint_handler_not_ready = True
345
346 # Stuff to do at closing time
343 # Stuff to do at closing time
347 self._kill = False
344 self._kill = False
348 on_kill = kw.get('on_kill')
345 on_kill = kw.get('on_kill')
@@ -413,18 +410,14 b' class MTInteractiveShell(InteractiveShell):'
413 tokill()
410 tokill()
414 print >>Term.cout, 'Done.'
411 print >>Term.cout, 'Done.'
415
412
416 # Install sigint handler. It feels stupid to test this on every single
413 # Install sigint handler. We do it every time to ensure that if user
417 # pass. At least we keep track of having done it before... We use a
414 # code modifies it, we restore our own handling.
418 # negative variable so we don't have to call 'not' every time
415 try:
419 if self._sigint_handler_not_ready:
416 signal(SIGINT,sigint_handler)
420 # Try only once...
417 except SystemError:
421 self._sigint_handler_not_ready = False
418 # This happens under Windows, which seems to have all sorts
422 try:
419 # of problems with signal handling. Oh well...
423 signal(SIGINT,sigint_handler)
420 pass
424 except SystemError:
425 # This happens under Windows, which seems to have all sorts
426 # of problems with signal handling. Oh well...
427 pass
428
421
429 # Flush queue of pending code by calling the run methood of the parent
422 # Flush queue of pending code by calling the run methood of the parent
430 # class with all items which may be in the queue.
423 # class with all items which may be in the queue.
General Comments 0
You need to be logged in to leave comments. Login now