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

Andrew Bennetts andrew at canonical.com
Mon Jul 16 03:38:50 BST 2007


Klaus Hartke wrote:
[...]
> This is the case for example if a host is down and the native sockets
> implementation tries to connect to it until a timeout occurs (which
> is, depending on the implementation, usually 90 to 300 seconds).
> During this time the user will see no progress. He has a 'cancel'
> button that doesn't work and his only option is to kill the process
> (i.e. Visual Studio). This is very frustrating.
> 
> I will go with PyErr_SetInterrupt() for now and continue looking for a
> better solution. Any idea or suggestion his highly welcome.

One solution I know of is to use a library that gives you a way to cancel an
in-progress operation, e.g. an event-driven non-blocking I/O framework like
Twisted.  Even that doesn't necessarily make it convenient, and can have its own
drawbacks, but it at least it makes it possible.

If you have to call a native function like something in libcurl, then you're
stuck with whatever libcurl supports.  If it doesn't support cancellation, then
the only portable and reliable option I know of is to run that operation in a
separate subprocess, which you can simply kill[1] when the user hits cancel.  Then
you have the hassle of marshalling data back-and-forth between the parent and
the child process, and also subprocesses tend to be slow to start, so again it's
not convenient, but it makes it possible.

Basically, all the options suck :(

-Andrew.

[1] There's no way to portably kill a subprocess, so you have to write code that
    uses os.kill or TerminateProcess depending on platform, but it can be done.




More information about the bazaar mailing list