##// 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 4 All the matplotlib support code was co-developed with John Hunter,
5 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 10 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
@@ -340,9 +340,6 b' class MTInteractiveShell(InteractiveShell):'
340 340 # enough, because uses like macros cause reentrancy.
341 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 343 # Stuff to do at closing time
347 344 self._kill = False
348 345 on_kill = kw.get('on_kill')
@@ -413,18 +410,14 b' class MTInteractiveShell(InteractiveShell):'
413 410 tokill()
414 411 print >>Term.cout, 'Done.'
415 412
416 # Install sigint handler. It feels stupid to test this on every single
417 # pass. At least we keep track of having done it before... We use a
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:
423 signal(SIGINT,sigint_handler)
424 except SystemError:
425 # This happens under Windows, which seems to have all sorts
426 # of problems with signal handling. Oh well...
427 pass
413 # Install sigint handler. We do it every time to ensure that if user
414 # code modifies it, we restore our own handling.
415 try:
416 signal(SIGINT,sigint_handler)
417 except SystemError:
418 # This happens under Windows, which seems to have all sorts
419 # of problems with signal handling. Oh well...
420 pass
428 421
429 422 # Flush queue of pending code by calling the run methood of the parent
430 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