[ANN] TortoiseHg-0.3
Steve Borho
steve at borho.org
Sun Feb 3 13:35:54 CST 2008
On Sun, 2008-02-03 at 11:13 -0800, David Ripton wrote:
> On 2008.02.02 22:54:06 -0600, Steve Borho wrote:
> > On Sat, 2008-02-02 at 20:07 -0800, Brad Schick wrote:
> > > -Would be nice to have a way to cancel running datamining searches. I
> > > ran two regexp searches that consumed 100% of the cpu and didn't end
> > > until I killed python (which I now can't repro).
> >
> > Anyone know how to stop a Python thread?
>
> There's no built-in, safe, easy way.
>
> You can write your threads such that they suicide upon command:
>
> class KillableThread(threading.Thread):
> time_to_die = False
>
> def please_die(self):
> self.time_to_die = True
>
> def run(self):
> while True:
> if self.time_to_die:
> return
> # Do a small amount of work here, without blocking too long
Most of TortoiseHg threads are calling the mercurial dispatch function,
so this usually isn't an option for us. Though I did use this method
for the web server dialog.
> But if you're calling a blocking library without timeouts that's outside
> your control, then that doesn't really work.
>
> One (cool, but possibly brittle or non-portable) option is to mess
> around inside Python's threading internals like:
> http://sebulba.wikispaces.com/recipe+thread2
Now that looks interesting. Thanks for the link.
> Another option is to call such libraries from within a subprocess.
> Killing processes is portable.
This would be too heavy weight for most operations we do.
--
Steve Borho (steve at borho.org)
http://www.borho.org/~steve/steve.asc
Key fingerprint = 2D08 E7CF B624 624C DE1F E2E4 B0C2 5292 F2C6 2C8C
More information about the Mercurial
mailing list