Newbie prob: How to write a file with 3 threads?

est electronixtar at gmail.com
Mon May 7 21:22:07 EDT 2007


On May 8, 1:29 am, Dennis Lee Bieber <wlfr... at ix.netcom.com> wrote:
> On 7 May 2007 00:13:46 -0700, est <electronix... at gmail.com> declaimed
> the following in comp.lang.python:
>
>
>
> > I'll try Queue.Queue, thank you. I didn't expect that multithread
> > write a file is so troublesome
>
>         Multiple writers to a file, threaded or not (ie, multiple processes,
> hosts on network, etc.), is always a pain unless one can ensure that all
> writers use a common locking mode to prevent overlapping calls. If all
> the writers are internal to one program, one can implement internal
> locks -- if external one needs OS support for multi-process locking (VMS
> common event flag clusters, for example). Easier to dedicate one
> (internal) writer and use the naturally locked Queue to control access.
> --
>         Wulfraed        Dennis Lee Bieber               KD6MOG
>         wlfr... at ix.netcom.com             wulfr... at bestiaria.com
>                 HTTP://wlfraed.home.netcom.com/
>         (Bestiaria Support Staff:               web-a... at bestiaria.com)
>                 HTTP://www.bestiaria.com/

I guess I will write multiple files, one thread one file, and after
all threads terminates, I combine the files. That's a cheaper
solution, I think.




More information about the Python-list mailing list