file write collision consideration
D'Arcy J.M. Cain
darcy at druid.net
Tue Jan 20 17:08:46 CET 2009
On Tue, 20 Jan 2009 10:57:52 -0500
RGK <blank at 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.
D'Arcy J.M. Cain <darcy at druid.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
More information about the Python-list