Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #39977

Re: Writing to same file from two threads

From Paul Rubin <no.email@nospam.invalid>
Newsgroups comp.lang.python
Subject Re: Writing to same file from two threads
Date 2013-02-26 09:32 -0800
Organization Nightsong/Fort GNOX
Message-ID <7xliabvv4g.fsf@ruckus.brouhaha.com> (permalink)
References <ap420lFiectU1@mid.uni-berlin.de>

Show all headers | View raw


jt@toerring.de (Jens Thoms Toerring) writes:
> in garbled output (i.e. having some output from A inside a
> line written by B or vice versae) because the "main thread" or

Yes they do get garbled like that.  Preferred Python style is put a
single thread in charge of all the i/o to that file, and communicate
with it by message passing through Queue objects.  That is safer than
directly using locks.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Writing to same file from two threads jt@toerring.de (Jens Thoms Toerring) - 2013-02-26 15:17 +0000
  Re: Writing to same file from two threads Paul Rubin <no.email@nospam.invalid> - 2013-02-26 09:32 -0800
    Re: Writing to same file from two threads jt@toerring.de (Jens Thoms Toerring) - 2013-02-26 20:08 +0000
      Re: Writing to same file from two threads Antoine Pitrou <solipsis@pitrou.net> - 2013-02-27 13:26 +0000
        Re: Writing to same file from two threads jt@toerring.de (Jens Thoms Toerring) - 2013-02-27 16:05 +0000
        Re: Writing to same file from two threads Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-28 01:05 +0000
          Re: Writing to same file from two threads Antoine Pitrou <solipsis@pitrou.net> - 2013-03-01 14:54 +0000

csiph-web