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


Groups > comp.lang.python > #76092

Re: Is print thread safe?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.021
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'cc:addr:python-list': 0.11; 'def': 0.12; '**kwargs)': 0.16; '**kwargs):': 0.16; '__future__': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'stdout': 0.16; 'wrote:': 0.18; 'import': 0.22; 'aug': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**0': 0.24; 'certain': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "d'aprano": 0.31; 'steven': 0.31; 'skip:_ 10': 0.34; 'received:google.com': 0.35; 'subject:?': 0.36; '12,': 0.39; 'either': 0.39; "you're": 0.61; 'problems?': 0.91; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=MV4a/PxCEWDt8tmia0sRX7lN/4ahZ+Rksbr55WBzZAI=; b=tvCZudaVebnLTF3WIOP/BiQKrD7r1Qi633TFX+WDEKAhVlLiHQxyNhonILLNby13JC 53nHS14Y2vhSwoYXXqOFQ3hePlLVUqRmGouVhHe9T+vo4q/rC5VswEAIy2D+wQ7tc3Ix dddafVAozTbMw3c0VogGhOD+zASaLZQ6Jmrx5LYZVnA8KfSGWPjxHKicYdJ1ktl/mro8 ybSGVCuQ14CQLzoeMfNchpIHx+7snR/S3CKm7atWZvK12U6UTN+At1AYDCUhP5b6yUm9 agjd/l/KQa/PjpHu/wStbsOj/kBTFnhC9ZffuH667y/FkVmFBpcm6q0nEZSNpm0azktg QEXA==
MIME-Version 1.0
X-Received by 10.42.230.212 with SMTP id jn20mr35722879icb.59.1407802469443; Mon, 11 Aug 2014 17:14:29 -0700 (PDT)
In-Reply-To <53e9583b$0$29973$c3e8da3$5496439d@news.astraweb.com>
References <53e8ea27$0$29981$c3e8da3$5496439d@news.astraweb.com> <mailman.12868.1407795799.18130.python-list@python.org> <53e9583b$0$29973$c3e8da3$5496439d@news.astraweb.com>
Date Tue, 12 Aug 2014 10:14:29 +1000
Subject Re: Is print thread safe?
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.12875.1407802477.18130.python-list@python.org> (permalink)
Lines 15
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1407802477 news.xs4all.nl 2927 [2001:888:2000:d::a6]:42304
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:76092

Show key headers only | View raw


On Tue, Aug 12, 2014 at 9:56 AM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> from __future__ import print_function
>
> _print = print
> _rlock = threading.RLock()
> def print(*args, **kwargs):
>     with _rlock:
>         _print(*args, **kwargs)

You're conflating print and stdout here. Do you know which one is the
cause of your problems? Alternatively, can you be certain that you
never use either without the other?

ChrisA

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


Thread

Is print thread safe? Steven D'Aprano <steve@pearwood.info> - 2014-08-11 07:44 +0000
  Re: Is print thread safe? INADA Naoki <songofacandy@gmail.com> - 2014-08-11 19:19 +0900
    Re: Is print thread safe? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-12 02:07 +1000
      Re: Is print thread safe? Cameron Simpson <cs@zip.com.au> - 2014-08-12 07:53 +1000
        Re: Is print thread safe? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-12 09:56 +1000
          Re: Is print thread safe? Chris Angelico <rosuav@gmail.com> - 2014-08-12 10:14 +1000
          Re: Is print thread safe? Marko Rauhamaa <marko@pacujo.net> - 2014-08-12 08:01 +0300
            Re: Is print thread safe? Cameron Simpson <cs@zip.com.au> - 2014-08-12 16:15 +1000
          Re: Is print thread safe? Cameron Simpson <cs@zip.com.au> - 2014-08-12 14:31 +1000
          Re: Is print thread safe? Chris Angelico <rosuav@gmail.com> - 2014-08-12 23:53 +1000

csiph-web