Hi > Trying to set up a timer function for my irc bot, which uses the python > irclib.py. > > If I use time.sleep(20), it tends to freeze up the bot completely for 20 > secs. That's not what I want though! I want the program to wait 20 secs, > then perform another function, but in the meantime be able to accept other > commands. > > How do I do that?
if I understand properly what you want to achieve, you will need to setup a separate execution thread import thread def f1(): return "hallo" def f2(): return " World" func_list = [f1, f2, lamda : "!!!"] def otherThread(sec): import time for i in func_list: print i(), time.sleep(sec) thread.start_new_thread(otherThread, (20, )) print "meanwhile print this message" i = raw_input("or let the user give some instructions") def xx(): pass xx() i hope this is what you are looking for my code is however untested, but should work -- http://mail.python.org/mailman/listinfo/python-list