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

Flavio Preto flavio.preto at gmail.com
Sun May 6 16:26:41 EDT 2007


Is it not possible to acomplish this with a token-based algorithm?

With 3 Threads: A, B and C

Thread A start with Token.
Thread with the token writes the byte and send the token to the next

Or python has any issues to a file object shared among a few threads?

[]'s
Flavio

On 5/6/07, Marc 'BlackJack' Rintsch <bj_666 at gmx.net> wrote:
>
> In <1178440537.257526.40980 at y5g2000hsa.googlegroups.com>, est wrote:
>
> > I need to write a file using 3 threads simutaniously, e.g. Thread 1
> > write the first byte of test.bin with an "a", second thread write the
> > second byte "b", third thread write the third byte "c". Anyone could
> > give a little example on how to do that?
>
> Simplest solution is: don't do that.  Write from one thread and send the
> date from the other threads via a `Queue.Queue` to the writing thread.
> Send the number of the thread with the data so the writer thread knows in
> which order the data has to be written.
>
> > I have my code, but it makes python intepreter crash everytime on my
> > Vista.
>
> Show minimal (non-)working  code, tell us the exception plus traceback and
> explain "crash".
>
> Ciao,
>         Marc 'BlackJack' Rintsch
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070506/71a04fc9/attachment.html>


More information about the Python-list mailing list