Killing a thread

MacDonald crazymykl at gmail.com
Sun Jun 11 16:43:04 EDT 2006


Fredrik Lundh wrote:
> crazymykl at gmail.com wrote:
>
> >> it cannot be done in a portable way, so that's not very likely.
>
> >   def __run(self):
> >     """Hacked run function, which installs the trace."""
> >     sys.settrace(self.globaltrace)
> >     self.__run_backup()
> >     self.run = self.__run_backup
>
> I'm not sure using a non-portable API to run the code under a "custom
> debugger" qualifies as a "portable implementation", though...

Everything used is a part of the standard library, which is portable,
AFAICT. Could you say specifically what is non-portable?

> have you benchmarked this, btw?

It has some overhead, but it should only be used in situations where
one line will either return before the timeout or take far too long. E.
g. an eval() statement with code generated from user input should
return quickly for reasonable entries, but something like "9**9**9"
will trigger the timeout.

> </F>




More information about the Python-list mailing list