"Matar" hilos en python

Raydel Miranda Gomez rmiranda en estudiantes.uci.cu
Sab Feb 21 19:09:54 CET 2009


Prueba con threading.Evnt
=================================================================
import time
import threading


class MyThread(threading.Thread):
	def __init__(self):
		threading.Thread.__init__(self)
		self.__event = threading.Event() # <-------
		
	def run(self):
		while not self.__event.isSet():  # <--------
			time.sleep(1)
			print "Running ..."
			
	def getEvent(self):
		return self.__event
		
	Event = property(getEvent, None, None, None)
			

if __name__ == "__main__":
	t = MyThread()
	t.start()
	time.sleep(5)
	t.Event.set()
=================================================================

-- 
Raydel Miranda Gómez.
Líder el proyecto Serere, instalador de GNU/Linux Nova.
email: rmiranda en estudiantes.uci.cu
------------ próxima parte ------------
_______________________________________________
Lista de correo Python-es 
http://listas.aditel.org/listinfo/python-es
FAQ: http://listas.aditel.org/faqpyes


Más información sobre la lista de distribución Python-es