On Tue, 20 Jan 2009 11:08:46 -0500, D'Arcy J.M. Cain wrote: > On Tue, 20 Jan 2009 10:57:52 -0500 > RGK <bl...@empty.blank> wrote: >> I have a thread that is off reading things some of which will get >> written into a file while another UI thread manages input from a user. >> >> The reader-thread and the UI-thread will both want to write stuff to the >> same output file. What first comes to mind is that there may be write >> collisions, ie both trying to write at the same time. > > Why not create a third thread that handles the write? The other > threads can simply add objects to a queue. You will still need > collision handling in the queue adder but it only needs to block for a > small time as opposed to the much longer disk write time.
IIRC, Queue.Queue objects handle by themselves multi-thread access, that is there is no need to additional locking mechanism ... Ciao --- FB -- http://mail.python.org/mailman/listinfo/python-list