[ZODB-Dev] ZODB-Dev Digest, Vol 118, Issue 7

Claudiu Saftoiu csaftoiu at gmail.com
Thu Jan 10 17:17:49 UTC 2013


Hey Vincent,

Thanks for the detailed reply! That really clears things up.

> > - Are there any other caching options?
> The option to make pickle cache persistent comes to mind. There may be
others,
> I don't recall right now.

This seems like a good idea - I would like for the server to maintain its
cache when I restart it (which is fairly often as I'm always working on
it). However, I seem to have run into some problems. I tried this uri
(added newlines for ease of reading):

zeo://%(here)s/zeo.sock?
     cache_size=2000MB&
     connection_cache_size=500000&
     connection_pool_size=15&
     var=zeocache&
     client=main

Yet I get a "zc.lockfile.LockError: Couldn't lock 'zeocache/main-1.zec.lock'"
error. I've tried googling it and it seems like this happens if multiple
processes attempt to access the same database if one isn't using ZEO, but I
am using ZEO and this is only related to the cache. I'm using paster to
serve the app and I don't think it creates multiple processes. Why might
this be happening? Here is my `app` function that paster uses to get the
wsgi app along with all relevant code:

import logging
import time
import threading

from repoze.bfg.configuration import Configurator
from repoze.zodbconn.finder import PersistentApplicationFinder

from util.pyshell import in_shell

from mainapp.models import appmaker
from mainapp import server_threads

def check_start_threads():
    time.sleep(5)
    if not in_shell():
        server_threads.start_server_threads()

def app(global_config, **settings):
    logging.basicConfig()

    zodb_uri = global_config.get('zodb_uri')
    if zodb_uri is None:
        raise ValueError("No 'zodb_uri' in application configuration.")

    zcml_file = settings.get('configure_zcml', 'configure.zcml')

    finder = PersistentApplicationFinder(zodb_uri, appmaker)
    def get_root(request):
        return finder(request.environ)
    config = Configurator(root_factory=get_root, settings=settings)
    config.begin()
    config.load_zcml(zcml_file)
    config.end()

    th = threading.Thread(target=check_start_threads)
    th.start()

    return config.make_wsgi_app()


Seems fairly straightforward, no?

- Claudiu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.zope.org/pipermail/zodb-dev/attachments/20130110/aa286b6e/attachment.html>


More information about the ZODB-Dev mailing list