Skip to main content

Synchronization primitives for ndb tasklets on Google App Engine (GAE)

Project description

Inspired by pythons new asyncio, this package implements the most basic synchronization primitives to work with ndb’s tasklets for the Google AppEngine (GAE)

Install

pip install ndb-x

Usage

We have the three primitives Lock, Semaphore and BoundedSemaphore. Usage is, what you expect, straightforward:

from google.appengine.ext import ndb
from ndbx.locks import Lock


lock = Lock()


@ndb.tasklet
def work_async():
    # using a context-manager will release the lock automatically
    with (yield lock.acquire()):
        rv = yield do_something_async()


@ndb.tasklet
def traditional_flow():
    yield lock.acquire()
    try:
        # do something
    finally:
        lock.release()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ndb-x-0.0.1.zip (8.2 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page