jarrod roberson
2006-May-03 04:25 UTC
[Xapian-discuss] Twisted + Xapian WriteableDatabase leaves db_lock file on exit.
Twisted Sumo 2006-02-12 xapian and xapian bindings 0.9.2 svn 6532 I have written a Twisted service to write to a xapian database. I am using WriteableDatabase using DB_CREATE_OR_OPEN. I am also using twistd and the application plumbing to start the server. I have tried everything but no matter how I stop the server I can't get it to shutdown xapian cleanly. I have implemented stopService() on my service and do a .flush() and have even tried setting the db instance to None and tried using del self.db as well. I even added a reactor.addSystemEventTrigger() and tried "before", "during" and "after" "shutdown" and nothing seems to work. I stop the service with CTRL-C, kill -TERM `cat twistd.pid' and just plain kill 'cat twistd.pid' It leaves the db_lock file everytime and I don't know what else it might not be cleaning up correctly either. Has anyone gotten a WritableDatabase to work with Twisted? If so, how do I stop Twisted so it will shutdown xapian cleanly?
Olly Betts
2006-May-03 14:07 UTC
[Xapian-discuss] Twisted + Xapian WriteableDatabase leaves db_lock file on exit.
On Tue, May 02, 2006 at 11:25:25PM -0400, jarrod roberson wrote:> xapian and xapian bindings 0.9.2 svn 6532That's rather old - is this reproducible with 0.9.5?> It leaves the db_lock file everytime and I don't know what else it might not > be cleaning up correctly either.The db_lock file gets deleted when the C++ WritableDatabase destructor is called. So if it's not deleted, then the destructor isn't being called. If you can reproduce with the latest release in a simple example (ideally without twisted being involved), I can try to investigate. Cheers, Olly
Terry Jones
2006-May-03 15:44 UTC
[Xapian-discuss] Twisted + Xapian WriteableDatabase leaves db_lock file on exit.
Hi Jarrod>>>>> "jarrod" == jarrod roberson <jarrod@vertigrated.com> writes:jarrod> I have written a Twisted service to write to a xapian database. jarrod> I am using WriteableDatabase using DB_CREATE_OR_OPEN. jarrod> I am also using twistd and the application plumbing to start the jarrod> server. jarrod> I have tried everything but no matter how I stop the server I can't jarrod> get it to shutdown xapian cleanly. I'd like to know the answer, when you get it (assuming it's not just an old version of Xapian). Funnily enough, I ran into exactly the same problem last night, but in a different context. I have some objects that have BSD databases open. I tried to close the databases in a __del__() method when the objects are destroyed. But I couldn't make it work. On closer inspection, it turned out that __del__ wasn't even being called. Maybe that's your case too. In the end I wrote my own close() method, which I now have to remember to call before my objects go out of scope. I don't know python very well. From what I read (google(__del__ not being called) gets plenty of hits), there is no guarantee that __del__ will ever be called and, it seems, even less guarantee if the interpreter itself is about to go away. Maybe someone with more knowledge of python can clarify this. Regards, Terry