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: 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> <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 Cc: "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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On Tue, Aug 12, 2014 at 9:56 AM, Steven D'Aprano 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