Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id DA4B1431FAF for ; Mon, 23 Apr 2012 15:45:27 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9EJoSm1zJ7WM for ; Mon, 23 Apr 2012 15:45:26 -0700 (PDT) Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com [74.125.83.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 5B548431FAE for ; Mon, 23 Apr 2012 15:45:26 -0700 (PDT) Received: by eekb47 with SMTP id b47so17209eek.26 for ; Mon, 23 Apr 2012 15:45:23 -0700 (PDT) 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:to :cc:content-type:content-transfer-encoding; bh=Mw+5107Em+k4IeaifxjICdR6z2LCM/P0wyPcYzcBQ54=; b=XojguKhbBk5PVo6u7YZJFqJf+baf6MzlMM+bgsgV5+43sQ0jak3iWYfDTX/XpehQBw YK8KQ8yooKWLn8eUD6n9Jj9ymjL6Kr0uE7cCtAoTP1AwQH8swff/OVCV4VXGeLU0coTI yiEyO7p7k3HDU7zqtphQB5+Z9EGM1Oo6TMlg7ya1NSuI91HFD1mKvxQpZidInv7uue/D ZS/Jfstfq4mc5A47mSiP8AZN5fTPfB94Kr+eRnlliQ77LhR0Qb+Dgb5mSuSOOa/1mgMt +HVeuOooMW9800ixIJQPXrkbD1sH2eNyoICJ+B1fncZsvFMFtIJKSfuNjNV3jaMdzpjW MFfQ== MIME-Version: 1.0 Received: by 10.213.9.209 with SMTP id m17mr1424450ebm.19.1335221123501; Mon, 23 Apr 2012 15:45:23 -0700 (PDT) Received: by 10.213.103.18 with HTTP; Mon, 23 Apr 2012 15:45:23 -0700 (PDT) In-Reply-To: References: <1335185032-13075-1-git-send-email-felipe.contreras@gmail.com> Date: Tue, 24 Apr 2012 01:45:23 +0300 Message-ID: Subject: Re: [PATCH] ruby: make sure the database is closed From: Felipe Contreras To: Ali Polatel Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: notmuch@notmuchmail.org X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Apr 2012 22:45:28 -0000 On Mon, Apr 23, 2012 at 11:43 PM, Ali Polatel wrote: > 2012/4/23 Felipe Contreras : >> On Mon, Apr 23, 2012 at 5:04 PM, Ali Polatel wrote: >> >>> I'd rather not do this. >>> Please read: http://comments.gmane.org/gmane.comp.lang.ruby.general/320= 324 >> >> OK, I've read this.. So? > > You are one step close to what I thought you had thought. I don't parse that. I meant that _now_ I've read it. >> The order in which Ruby's garbage-collector frees the database and >> other objects is irrelevant, because with this patch we are not >> manually freeing other objects, only the database. > > What I wanted was to make all objects "depending" on the database to be u= nusable > once the database object is freed. Seeing that's not practically easy > I decided to leave > it to the user. Well, sure, but if the user has problems, the user can keep the database object around. Personally I don't see why an object, like say a query would remain working correctly after the database is gone, either by calling .close() directly, or just loosing the pointer to the original object. I don't think users would expect that, or, even if they somehow found it useful, that most likely would be very seldom, and hardly worth worrying about it. >> Sure, it's _better_ if the user calls close(), even better if it's >> inside an 'ensure', and even better if blocks are used (which I am >> using in most cases), but that's not *required*. > > If you have such a use case, I'm fine with that patch. > I might push it in the next few days or get someone else to push it. I did at some point, not sure if I do now. But that's beside the point, the point is that it really does happen. >> The user might just do: >> >> def foo >> =C2=A0db =3D Notmuch::Database.new($db_name, :mode =3D> Notmuch::MODE_RE= AD_WRITE) >> end >> >> That's perfectly fine in Ruby (although not ideal), since 'db' will >> get garbage-collected. But nobody will be able to use the database >> again until that process is killed. >> >> You think that's correct? > > Yes that is correct. I have not thought about this. > I'd say it's a partial misunderstanding on my part due to lack of > (and/or too much) vodka. Well, there's only two options. a) This works: def foo db =3D Notmuch::Database.new($db_name, :mode =3D> Notmuch::MODE_READ_WR= ITE) end (as in; the database gets closed eventually) b) This works: def start_query(search) db =3D Notmuch::Database.new($db_name) return db.query(search) end (as in; the query returned would keep working properly) I personally don't see why anybody would want b), and if they have problems with code like that, I think it's obvious to see why. I think we should go for a) and thus apply the patch. Cheers. --=20 Felipe Contreras