[Tutor] How to deal with a thread that doesn't terminate

John Fouhy john at fouhy.net
Wed Feb 20 00:57:54 CET 2008


On 20/02/2008, bob gailer <bgailer at alum.rpi.edu> wrote:
> Tony Cappellini wrote:
> > On Feb 19, 2008 2:02 PM, bob gailer <bgailer at alum.rpi.edu> wrote:
> >
> >> Tony Cappellini wrote:
> >>
> >>> When I executing a program external to the main program in a thread,
> >>> and that thread hangs, can the thread be terminated?
> >>>
> >>>
> >> Please define "hangs".
> >>
> >
> >
> >> AFAIK that could mean waiting on an external event / signal /
> >> communication that never happens, or running in an "infinite loop". So
> >> which is it or is it something else?
> >>
> >
> > Never happens.
> >
>
> Sorry. I don't understand that, so I can't help. Perhaps someone else can.

I presume he means he defines "hangs" as "waiting on an external event
/ signal / communicaiton that never happens".

AFAIK, there's no good way to kill a thread (google for 'python kill
thread' for lots of hits).  IME most blocking operations have optional
timeout parameters, so you could restructure your main thread loop to
wait->work/timeout->repeat, which should make it easier to end the
thread.

-- 
John.


More information about the Tutor mailing list