Python bindings and Xapian exceptions

Sebastian Spaeth Sebastian at SSpaeth.de
Fri Nov 5 00:25:38 PDT 2010


On Thu, 04 Nov 2010 12:31:48 -0700, Carl Worth <cworth at cworth.org> wrote:
> On Tue, 15 Jun 2010 11:03:55 +0200, "Sebastian Spaeth" wrote:
> > >   A Xapian exception occurred finding message: The revision being read
> > >   has been discarded - you should call Xapian::Database::reopen() and
> > >   retry the operation.
> > > It makes the Python bindings almost useless to me.

> > The proper fix, and a reason why I am not immediately hacking around in
> > the python bindings is that notmuch the library would actually return a
> > proper error value rather than print to stderr and quit.
> 
> For this particular case, I think the correct thing is for the library
> to simply do the reopen() itself.

That would already help a lot. But if there is for example a background
task running that modifies the database a lot, reopening once might
still not suffice. So we should try to reopen, yes. But if it still does
not work after a reopen, we still need the possibility to fail
gracefully while notifying the user about the failure.

> But for exceptions in general, yes the notmuch library does need to be
> fixed to allow the caller of functions to distinguish between things
> like "no matches found" and "an exception occurred, so it's unknown if
> any messages match the search". That's a general class of library
> interface bugs that all need to be fixed.

It does return a status for many operations already which is good. THere
are only a few cases where it does not and the only one I know off-hand
is find_message() which is useless at the moment as its result cannot be
trusted. 

What would probably also be good if notmuchlib could export a
database.reopen() command so bindings can reopen the database in case
they need to, without having to have xapian development headers
installed and linking to it directly. Of course if libnotmuch reopens
itself, that would not be required.

Sebastian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20101105/2b943e42/attachment.pgp>


More information about the notmuch mailing list