threads and sleep?
andreas at kostyrka.org
Wed Jul 13 09:36:19 CEST 2005
Am Montag, den 04.07.2005, 15:36 -0400 schrieb Jeffrey Maitland:
> Hello all,
Ok, first thing to consider is that time.sleep in Python does in reality
(on Debian Linux, Python2.3) a select syscall with 3 NULLs to wait the
time. (The "real" sleep POSIX call might have stupid interactions with
signals, to be specific SIGALRM) Don't have a Python source at the
moment (I'm offline at the moment) to check how it's done in Win32.
> 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:
> t = threading.Thread( target = func1, args = "String") #note
> this is probably non functional (example purposes for the question
> temp_var = t.isAlive()
> print "This line should display a lot"
> 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?
Well, your program seems to be non-functional (missing if expression?),
but as I said above, the main thread waits via select, so the child
process should be able to run in this time (assuming time.sleep releases
the GIL, but I'd file it as a bug if it doesn't).
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 196 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
More information about the Python-list