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


Groups > comp.lang.python > #20673

Re: Should I acquire lock for logging.Handler.flush()?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <fayaz.yusuf.khan@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'architect': 0.03; 'handler': 0.04; 'received:localnet': 0.07; 'url:py': 0.07; 'content-type:multipart/signed': 0.09; 'filename:fname piece:signature': 0.09; 'handler.': 0.09; 'oh,': 0.09; 'subclass': 0.09; 'url:github': 0.09; 'developer': 0.12; 'skip:f 30': 0.13; 'method.': 0.15; 'bangalore,': 0.16; 'close()': 0.16; 'content- type:application/pgp-signature': 0.16; 'docs.': 0.16; 'filename:fname piece:asc': 0.16; 'filename:fname:signature.asc': 0.16; 'flush()': 0.16; 'implemented.': 0.16; 'limiting.': 0.16; 'sajip': 0.16; 'subject:lock': 0.16; 'url:blob': 0.16; 'vinay': 0.16; 'wrote:': 0.18; 'instance': 0.18; 'header:In-Reply-To:1': 0.22; 'feb': 0.22; 'somewhere': 0.26; 'module': 0.26; 'cloud': 0.28; "i'm": 0.28; 'locked': 0.30; 'received:209.85.210.46': 0.30; 'received:mail-pz0-f46.google.com': 0.30; 'url:library': 0.31; 'skip:( 20': 0.31; 'source': 0.32; 'implement': 0.32; "isn't": 0.33; "won't": 0.33; 'header:User-Agent:1': 0.33; 'calling': 0.34; 'probably': 0.35; 'to:addr:python-list': 0.35; 'things': 0.35; 'url:python': 0.35; 'but': 0.37; 'charset:us-ascii': 0.37; 'received:google.com': 0.37; 'using': 0.37; 'skip:_ 10': 0.38; 'received:209.85': 0.38; 'doing': 0.38; 'should': 0.38; 'url:org': 0.39; 'received:209': 0.39; 'called': 0.40; 'being': 0.40; 'to:addr:python.org': 0.40; "you'll": 0.61; 'header:Received:6': 0.61; 'skip:+ 10': 0.64; 'here': 0.64; 'it)': 0.67; 'anything.': 0.71; 'no!': 0.84; 'received:111': 0.84; 'yusuf': 0.84; 'tuesday': 0.91
Received-SPF pass (google.com: domain of fayaz.yusuf.khan@gmail.com designates 10.68.218.167 as permitted sender) client-ip=10.68.218.167;
Authentication-Results mr.google.com; spf=pass (google.com: domain of fayaz.yusuf.khan@gmail.com designates 10.68.218.167 as permitted sender) smtp.mail=fayaz.yusuf.khan@gmail.com; dkim=pass header.i=fayaz.yusuf.khan@gmail.com
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:subject:date:message-id:user-agent:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=/IjumQAxUUoLS4KAuVHhfx3z4Sbnr3gwcQckPRVw4Ss=; b=tXdtkWY9cjKrUHHu/pft9GeSdlmKLGruJMwnQZckB7nY+HnUtnwON+C43+HY0DNFiB VCs8G4fW4ASxSg+gtfA9gmzfbVlZan2mbySMpm2hLpLHKXd7Odc1JaV1Lf0zNgNNRYbA DBK16lBRD37QvzZIIEZLiNDmMmDmQ2scZ8tNg=
From Fayaz Yusuf Khan <fayaz.yusuf.khan@gmail.com>
To python-list@python.org
Subject Re: Should I acquire lock for logging.Handler.flush()?
Date Wed, 22 Feb 2012 10:14:44 +0530
User-Agent KMail/4.7.3 (Linux/3.0.0-16-generic; KDE/4.7.4; i686; ; )
In-Reply-To <0e8f8dd1-ffe7-42fd-bc95-82ea60358f04@n12g2000yqb.googlegroups.com>
References <mailman.26.1329809252.3037.python-list@python.org> <0e8f8dd1-ffe7-42fd-bc95-82ea60358f04@n12g2000yqb.googlegroups.com>
MIME-Version 1.0
Content-Type multipart/signed; boundary="nextPart5031124.Wr8jmjfSXL"; micalg="pgp-sha1"; protocol="application/pgp-signature"
Content-Transfer-Encoding 7Bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.36.1329885907.3037.python-list@python.org> (permalink)
Lines 49
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1329885907 news.xs4all.nl 6901 [2001:888:2000:d::a6]:36558
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:20673

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Tuesday 21 Feb 2012 12:52:14 PM Vinay Sajip wrote:
> If you are using SMTPHandler, calling flush() won't do anything.
> You'll probably need to subclass the handler to implement rate
> limiting.
Oh, no! I'm writing my own handler.
https://github.com/fayazkhan/ses_handler/blob/master/ses_handler.py
Now I understand from here 
http://docs.python.org/library/logging.html#handler-objects
that emit() calls are wrapped acquire() and release() in the handle() method.

Anyway, I read the source and found many interesting things that ought to be 
mentioned in the docs.
Such as flush() should be called from close() whenever it's implemented. 
(FileHandler.close() is doing it)
And how come close()/flush() isn't being called from inside a lock?
(Handler.close() calls the module level _acquireLock() and _releaseLock()s but 
nothing about the instance level acquire() or release())
Or is it being locked from somewhere else?
-- 
Fayaz Yusuf Khan
Cloud developer and architect
Dexetra SS, Bangalore, India
fayaz.yusuf.khan_AT_gmail_DOT_com
fayaz_AT_dexetra_DOT_com
+91-9746-830-823

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


Thread

Should I acquire lock for logging.Handler.flush()? Fayaz Yusuf Khan <fayaz.yusuf.khan@gmail.com> - 2012-02-21 12:53 +0530
  Re: Should I acquire lock for logging.Handler.flush()? Vinay Sajip <vinay_sajip@yahoo.co.uk> - 2012-02-21 12:52 -0800
    Re: Should I acquire lock for logging.Handler.flush()? Fayaz Yusuf Khan <fayaz.yusuf.khan@gmail.com> - 2012-02-22 10:14 +0530
      Re: Should I acquire lock for logging.Handler.flush()? Vinay Sajip <vinay_sajip@yahoo.co.uk> - 2012-02-23 08:23 -0800
        Re: Should I acquire lock for logging.Handler.flush()? Fayaz Yusuf Khan <fayaz.yusuf.khan@gmail.com> - 2012-02-23 23:25 +0530
          Re: Should I acquire lock for logging.Handler.flush()? Vinay Sajip <vinay_sajip@yahoo.co.uk> - 2012-02-23 11:08 -0800
          Re: Should I acquire lock for logging.Handler.flush()? Vinay Sajip <vinay_sajip@yahoo.co.uk> - 2012-02-23 12:06 -0800

csiph-web