[Xapian-discuss] Twisted + Xapian WriteableDatabase leaves
db_lock file on exit.
jarrod roberson
jarrod at vertigrated.com
Wed May 3 16:45:56 BST 2006
On 5/3/06, James Aylett <james-xapian at tartarus.org> wrote:
>
> On Wed, May 03, 2006 at 11:26:21AM -0400, jarrod roberson wrote:
>
> > the problem is I can't reproduce it outside of Twisted.
> >
> > all my command line tools that I have written ( all in Python ) that use
> the
> > exact same code exit and close properly.
>
> Is the reference inside a thread in twisted? We've had problems there,
> although I can't remember any details at all.
No it is just in a "Service" class
here is what I have tried, I snipped all the app specific logic, here is
whare I open the db, and try to close it.
When the server shuts down, the stopService() gets called and prints out the
message as well
#
# Service Implementations
======================================================
#
class XapianIndexerService(service.Service):
implements(IndexerService)
def __init__(self, fileRoot, indexRoot, flushInterval=60):
self.fileRoot = fileRoot
self.db = xapian.WritableDatabase(indexRoot, xapian.DB_CREATE_OR_OPEN
)
self.flushInterval = flushInterval
def startService(self):
print 'Start Xapian Index Service'
self.periodicFlush = task.LoopingCall(self.db.flush)
self.periodicFlush.start(self.flushInterval)
def index(self, path):
#
# details snipped but this is where I create the
# documents and add or replace them
#
def remove(self, docID):
# delete document from xapian database
self.db.delete_document(docID)
def stopService(self):
print 'Stopping Xapian Indexer Service'
self.periodicFlush.stop()
self.db.flush()
#
# Application
==================================================================
#
application = service.Application('wfsindexer')
i = XapianIndexerService('/wfs/', '/index/wfs/')
serviceCollection = service.IServiceCollection(application)
i.setServiceParent(serviceCollection)
internet.TCPServer(9000, IndexerFactory(i)
).setServiceParent(serviceCollection)
def delService(i):
del i
# I tried every phase and they all do the same thing.
reactor.addSystemEventTrigger( 'before', 'shutdown', delService, i )
More information about the Xapian-discuss
mailing list