threads and sleep?

Jeffrey Maitland jeff.maitland at gmail.com
Mon Jul 4 15:36:16 EDT 2005


Hello all,

I am in the process of writing a multithreading program and what I was
wondering is a sleep command in an executing function will affect the
threads below it? Here is a basic example of what I mean.

def main():
   temp_var = True
   while temp_var == True:
       if
          t = threading.Thread( target = func1, args = "String") #note
this is probably non functional (example purposes for the question
only)
          t.start()
          temp_var  =  t.isAlive()
       else: 
           print "This line should display a lot"
           sleep(2)

def func1(s):
  print s

so the question I was wondering is if the sleep will pause the t
thread as well as the main function or is the thread independat of the
main function sleep?

Thanks in advance.



More information about the Python-list mailing list