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

Ville M. Vainio vivainio@gmail....
Fri Aug 7 03:55:18 CDT 2009


Thanks Pieter, cc:ing to ipython-dev.

Someone might want to cherry-pick the following change from my
trunk-dev and put it to trunk:

http://bazaar.launchpad.net/~villemvainio/ipython/trunk-dev/revision/1160



---------- Forwarded message ----------
From: Pieter Cristiaan de Groot <p.c.degroot@tudelft.nl>
Date: Fri, Aug 7, 2009 at 11:18 AM
Subject: Re: [IPython-dev] ctrl-c bug using -gthread on windows, with
possible solution
To: "Ville M. Vainio" <vivainio@gmail.com>


Hello Ville,

it looks like the ctrl-c bugfix for gthread didn't make it to 0.10.
The error is still easily reproducable by starting ipython with
-ghread. Type sleep(10), en then ctrl-c (in windows).

The suggest change is:

before:

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


after:

      try:
          update_tk(self.tk)
          self.IP.runcode()
          time.sleep(0.01)
          return True
      except IOError:
          return True

Best regards,

Pieter

Pieter Cristiaan de Groot wrote:
>
> 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?
>>
>>
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev@scipy.org
> http://lists.ipython.scipy.org/mailman/listinfo/ipython-dev
>



-- 
Ville M. Vainio
http://tinyurl.com/vainio


More information about the IPython-dev mailing list