Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using dbm locking one can not create values with nested creators #5

Closed
sqlalchemy-bot opened this issue May 2, 2012 · 6 comments
Closed
Labels
bug Something isn't working

Comments

@sqlalchemy-bot
Copy link

Migrated issue, originally created by kaukas (kaukas)

Sometimes it is desired to cache not only the final result of the computation but the intermediate steps as well. Doing that you can invalidate the result of some of the steps and the final cache. The recomputation of the final result would then be faster because it would still use the rest of the cached values.

Example:

#!python

from dogpile.cache import make_region

region = make_region()
region.configure('dogpile.cache.dbm',
    arguments=dict(
        filename='file.dbm'
    )
)


def create_small_thing():
    def small_thing():
        return 'small '
    return region.get_or_create('small', creator=small_thing)


def create_big_thing():
    def big_thing():
        return create_small_thing() * 10
    return region.get_or_create('big', creator=big_thing)

create_big_thing()

The above code freezes - once the lock is acquired for the "big thing" you can not store "small things".

@sqlalchemy-bot
Copy link
Author

Michael Bayer (zzzeek) wrote:

is that the file lock freezing ? OK we can make it re-entrant, perhaps beaker's did this already

@sqlalchemy-bot
Copy link
Author

Michael Bayer (zzzeek) wrote:

oh, that's the dogpile. OK might want to put a reentrant decorator around the lock in a generic way....hooray latency

@sqlalchemy-bot
Copy link
Author

Michael Bayer (zzzeek) wrote:

still thinking sorry ! the dbm backend's lock is across all keys. other locks dont. so maybe a reentrant proxy chosen by the backend depending on the type of lock.

@sqlalchemy-bot
Copy link
Author

Changes by kaukas (kaukas):

  • changed title from "Using dbm locking one can not create more than one" to "Using dbm locking one can not create values with n"

@sqlalchemy-bot
Copy link
Author

Michael Bayer (zzzeek) wrote:

okey doke got something for this in [[https://bitbucket.org/zzzeek/dogpile.cache/changeset/c2e2571f326f5a990a52c75f4739800012c82493|c2e2571f326f5a990a52c75f4739800012c82493]]. Should be good to release 0.2.3.

@sqlalchemy-bot
Copy link
Author

Changes by Michael Bayer (zzzeek):

  • changed status to closed

@sqlalchemy-bot sqlalchemy-bot added the bug Something isn't working label Nov 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant