unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* notmuch as a shared object aka library knigge
@ 2012-02-21  0:29 Justus Winter
  2012-02-21 15:35 ` Patrick Totzke
  2012-02-21 15:53 ` Austin Clements
  0 siblings, 2 replies; 9+ messages in thread
From: Justus Winter @ 2012-02-21  0:29 UTC (permalink / raw)
  To: notmuch mailing list

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 = os.path.expanduser('~/Maildir')

with notmuch.Database(db_path, mode=notmuch.Database.MODE.READ_ONLY) as db:
    db.get_directory('')
~~~ snap ~~~

% python temp/get_directory.py
Internal error: Failure to ensure database is writable (lib/directory.cc:100).

The line mentioned in the error message reads:

    if (notmuch->mode == 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-02-24  1:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-21  0:29 notmuch as a shared object aka library knigge Justus Winter
2012-02-21 15:35 ` Patrick Totzke
2012-02-21 15:53 ` Austin Clements
2012-02-22 15:17   ` Justus Winter
2012-02-23 22:22     ` Justus Winter
2012-02-24  0:29       ` David Bremner
2012-02-24  1:04         ` Justus Winter
2012-02-24  0:33       ` David Bremner
2012-02-24  1:08         ` Justus Winter

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).