xapian exceptions not caught in python bindings?

Subject: xapian exceptions not caught in python bindings?

Date: Sun, 26 Jun 2011 21:27:33 +0100

To: notmuch@notmuchmail.org

Cc:

From: Patrick Totzke


Hi all!
It's me again, with some strange python behaviour :/

When I iterate over threads or messages only partially,
then make changes to the index and continue the iteration,
then I don't necessarily get NotmuchError's but the underlying
libnotmuch seems to call terminate. I get the following two lines on
stderr:
  terminate called after throwing an instance of 'Xapian::DatabaseModifiedError'
  Aborted
then python aborts without an exception.
This happens on current master with current python bindings. To reproduce
use this to iterate over messages:

------------------%<-------------------
#it_read.py
from notmuch import Query,Database
msgs = Database().create_query('*').search_messages()

i=0
for m in msgs:
    i=i+1
    if i%50==0:
        raw_input()
    readit = str(m)
------------------>%-------------------

start it, then use this to change the index:

------------------%<-------------------
#it_write.py 
from notmuch import Query,Database
db = Database(mode = Database.MODE.READ_WRITE)
msgs = Query(db,'*').search_messages()

i=0
for m in msgs:
    i=i+1
    if i%20==0:
        m.add_tag('REMOVEME')
------------------>%-------------------

you have to alternate a bit between hitting enter in the
read code and rerunning the write code.
Read will fail at some point.

The strange thing is that its not consistent:
I stumbled upon this while reading a list of threads from notmuch.threads on
demand. If reading from the iterator catches a NotmuchError, i create a new one
and update my list threads read so far. This does work, but: on every
NotmuchError, I get this on stderr:
 A Xapian exception occurred performing query: The revision being read has been discarded - you should call Xapian::Database::reopen() and retry the operation
 Query string was: thread:0000000000001876

After a couple of resets this does not happen again but the next time i read
from an outdated index, the whole UI terminates with the "Aborted" message
stated above.

To sum up, I think there are two bad things happening here:
1) should libnotmuch really print to stderr?
2) the python bindings are either not relaying all exceptions or libnotmuch is not relaying 
all xapian exceptions in order for the bindings to intercept them

cheers,
/p
signature.asc (application/pgp-signature)

Thread: