[Baypiggies] multithreading question

Aahz aahz at pythoncraft.com
Wed Sep 17 23:17:51 CEST 2008


On Wed, Sep 17, 2008, Shannon -jj Behrens wrote:
>
> I know that threads are the devil and all, but I have a threading
> question ;)

What makes you say that threads are the devil?

> I'm using the queue module to coordinate a bunch of threads.  Those
> threads need to log a line to STDOUT.  The line is short.  Can I count
> on the GIL to make sure that writing a single line to STDOUT is
> atomic, or do I need to be more paranoid?

That depends really on the underlying OS library.  Mostly yes: a single
Python C-level call to fwrite() will be atomic.  So technically, you're
not counting on the GIL.  ;-)
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Argue for your limitations, and sure enough they're yours."  --Richard Bach


More information about the Baypiggies mailing list