[Tutor] question about importing threads

Kent Johnson kent37 at tds.net
Sat Dec 30 17:29:24 CET 2006


shawn bright wrote:
> Kent, Thanks.
> this is great. Yes, when i start the thread, i also pass the gtk object 
> to it.
> kinda like this.
> 
> serial_1 = Serial1(self.serial_1_buffer, self.serial_1_view)
> serial_1.start()
> 
> so i am wanting to change that, but i do not exactly know how to stop a 
> thread once i have it running, so that i could start another one.

The usual way to stop a thread is to set a flag that the thread checks. 
Here is an example using a threading.Event as a flag:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65448

> anyway, thanks for the link and the info, i am going to get started on 
> testing this right away. This long a .py script is becomming a headache 
> and i think it will be easier by far if it is pulled apart somewhat.

Yes, 4000 lines is pretty long for one file IMO.

Kent




More information about the Tutor mailing list