[IPython-dev] ctrl-c bug using -gthread on windows, with possible solution

Pieter Cristiaan de Groot p.c.degroot@tudelft...
Thu Feb 12 16:05:10 CST 2009


Just to be sure I answer your question fully:

case 1) the original 0.9.1 ipython code gives this error if I start it 
with -gthread and push ctrl-c

##########################

CODE (in Shell.py, around linenr. 840):

        update_tk(self.tk)
        self.IP.runcode()
        time.sleep(0.01)
        return True

ERROR:

KeyboardInterrupt - Press <Enter> to 
continue.---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)

c:\python25\lib\site-packages\IPython\Shell.pyc in on_timer(self)
    840         update_tk(self.tk)
    841         self.IP.runcode()
--> 842         time.sleep(0.01)
    843         return True
    844

IOError: [Errno 4] Interrupted function call

#################

case 2) catching the exception (with some prints):

###############

CODE:

        try:
            update_tk(self.tk)
            self.IP.runcode()
            time.sleep(0.01)
            return True
        except Exception, e:
            print type(e)
            print(e)
            return True

ERROR:

KeyboardInterrupt - Press <Enter> to continue. <type 'exceptions.IOError'>
[Errno 4] Interrupted function call

#########################

case 3) if I understood correctly this is what you wanted to see:

#####################

CODE:

        update_tk(self.tk)
        self.IP.runcode()
        try:
            time.sleep(0.01)
            return True
        except Exception ,e:
            print type(e)
            print e
            return True

ERROR:

KeyboardInterrupt - Press <Enter> to continue. <type 'exceptions.IOError'>
[Errno 4] Interrupted function call

##########################

case 3a) occasionally (1 in ~20 times), if you interrupt the code while 
it is not in the sleep, then everything works fine. It gives this message:

############################

CODE: (same as case 3, and probably the same for 1 and 2)

ERROR:

KeyboardInterrupt - Press <Enter> to continue.

###########################

I hope this answers your question. If you want me to check any more 
things, please ask.

Pieter

Ville M. Vainio wrote:
> On Thu, Feb 12, 2009 at 3:06 PM, Pieter Cristiaan de Groot
> <p.c.degroot@tudelft.nl> wrote:
>
>   
>> this is my last attempt to get the attention to this post. Even if this
>> is the wrong place to post to,
>> could somebody explain where it should be posted?
>>     
>
> This is the right place, you probably just didn't get lucky in drawing
> people's attention. Perhaps because people don't use gthread on
> windows all that much.
>
> Can you try catching the exception just for the sleep command?
>
>   


More information about the IPython-dev mailing list