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 8B820431FAF for ; Mon, 20 Feb 2012 16:29:30 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "Date" X-Spam-Flag: NO X-Spam-Score: 0.432 X-Spam-Level: X-Spam-Status: No, score=0.432 tagged_above=-999 required=5 tests=[INVALID_DATE=0.432] 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 aSJ7quxRkytu for ; Mon, 20 Feb 2012 16:29:29 -0800 (PST) Received: from mail.cryptobitch.de (cryptobitch.de [88.198.7.68]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id D22A9431FAE for ; Mon, 20 Feb 2012 16:29:28 -0800 (PST) Received: from mail.jade-hamburg.de (unknown [85.183.11.228]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.cryptobitch.de (Postfix) with ESMTPSA id 218E45312DC for ; Tue, 21 Feb 2012 01:29:27 +0100 (CET) Received: by mail.jade-hamburg.de (Postfix, from userid 401) id 180BBDF2A4; Tue, 21 Feb 2012 01:29:26 +0100 (CET) Received: from thinkbox.jade-hamburg.de (dslb-088-075-032-221.pools.arcor-ip.net [88.75.32.221]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: teythoon) by mail.jade-hamburg.de (Postfix) with ESMTPSA id 46CD7DF2A1 for ; Tue, 21 Feb 2012 01:29:25 +0100 (CET) Received: from teythoon by thinkbox.jade-hamburg.de with local (Exim 4.77) (envelope-from ) id 1Rzdbd-0002Sp-Ss for notmuch@notmuchmail.org; Tue, 21 Feb 2012 01:29:21 +0100 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Justus Winter <4winter@informatik.uni-hamburg.de> User-Agent: alot/0.21+ To: notmuch mailing list , Date: Tue, 21 Feb 2012 00:29:21 -0000 Message-ID: <20120221002921.8534.57091@thinkbox.jade-hamburg.de> Subject: notmuch as a shared object aka library knigge Date: Tue, 21 Feb 2012 01:29:21 +0100 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: Tue, 21 Feb 2012 00:29:30 -0000 Hi fellow notmuchrs, while going through the python bindings I recently came across the following note in the documentation for the Database.get_directory function [0]: ~~~ snip ~~~ Warning This call needs a writable database in Database.MODE.READ_WRITE mode. The underlying library will exit the program if this method is used on a read-only database! ~~~ snap ~~~ and indeed, the following program exits with an error: ~~~ snip ~~~ import os import notmuch db_path =3D os.path.expanduser('~/Maildir') with notmuch.Database(db_path, mode=3Dnotmuch.Database.MODE.READ_ONLY) as d= b: db.get_directory('') ~~~ snap ~~~ % python temp/get_directory.py Internal error: Failure to ensure database is writable (lib/directory.cc:10= 0). The line mentioned in the error message reads: if (notmuch->mode =3D=3D NOTMUCH_DATABASE_MODE_READ_ONLY) INTERNAL_ERROR ("Failure to ensure database is writable"); with /* There's no point in continuing when we've detected that we've done * something wrong internally (as opposed to the user passing in a * bogus value). * * Note that __location__ comes from talloc.h. */ #define INTERNAL_ERROR(format, ...) \ _internal_error (format " (%s).\n", \ ##__VA_ARGS__, __location__) and _internal_error calling exit(3). If creating a shared library is the preferred way to increase the startup time of the notmuch binary that's totally cool, but if libnotmuch is to be used as a library for arbitrary programs it is not acceptable to call exit(3). (And as mentioned before, neither is writing to any file descriptor unless it has been specifically requested by the caller.) Cheers, Justus 0: http://notmuch.readthedocs.org/en/latest/index.html#notmuch.Database.get= _directory