##// 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,12 +410,8 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
419 if self._sigint_handler_not_ready:
420 # Try only once...
421 self._sigint_handler_not_ready = False
422 try:
415 try:
423 signal(SIGINT,sigint_handler)
416 signal(SIGINT,sigint_handler)
424 except SystemError:
417 except SystemError:
General Comments 0
You need to be logged in to leave comments. Login now