Google Summer of Code: Bazaar-Visual Studio integration status update

Robert Collins robertc at robertcollins.net
Sat Jul 14 13:55:47 BST 2007


On Fri, 2007-07-13 at 23:30 +0200, Klaus Hartke wrote:
> I hoped someone could comment on this issue:
> 
> > * How does one cancel bzrlib.bzrdir.BzrDir.sprout or commit?
> 
> The only way to cancel a bzr operation seems to be a KeyboardInterrupt.

Right. bzr is synchronous blocking code, so the only way to interrupt it
is to have the operating system interject some code into the call stack.
Signals on unix style operating systems provide this facility quite
handily :).

> How does one raise a KeyboardInterrupt from a GUI?
> 
> There doesn't seem to be a way to raise a KeyboardInterrupt
> programmatically, i.e. to send a signal to an embedded CPython app.
> The only solution I found was to shutdown the Python interpreter and
> start a new one (which, of course, doesn't raise any exception).
> 
> Any hint appreciated.

This may be of interest :
http://mail.python.org/pipermail/python-dev/2007-March/071981.html

I think your best bet is a bit of a hack, but avoids this rather
completely:

 - register a custom UI object
 - have your progress bar class in the UI object check for a flag you
set when you want to cancel something.
 - raise an exception (e.g. OperationCancelled) when that flag is set.

HTH,
-Rob

-- 
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070714/2088fd57/attachment.pgp 


More information about the bazaar mailing list