Threading from a class

MRAB python at
Sun Oct 18 03:27:35 CEST 2009

Someone Something wrote:
> anyone?
> On Sat, Oct 17, 2009 at 4:26 PM, Someone Something <fordhaivat at 
> <mailto:fordhaivat at>> wrote:
>     I'm trying to write a IRC client that has to have a method inside
>     class Client that has to start a new thread that goes to run() which
>     is in the same class. I'm not really understanding all the threading
>     tutorials i've found. Can someone help?
>     p.s. trying to use the threading module, not the thread module.
# Written for Python v2.6

import threading
import time

class Client(object):
     def test_thread(self):
         print "starting thread"
         self.thread = threading.Thread(
         print "sleeping for 6 seconds"
         print "woken up"
     def run(self):
         for i in range(5):
             print i

c = Client()

More information about the Python-list mailing list