https://github.com/kaste/ndb-x
Synchronization primitives for ndb tasklets on Google AppEngine (GAE)
https://github.com/kaste/ndb-x
app-engine google-appengine
Last synced: about 1 year ago
JSON representation
Synchronization primitives for ndb tasklets on Google AppEngine (GAE)
- Host: GitHub
- URL: https://github.com/kaste/ndb-x
- Owner: kaste
- License: mit
- Created: 2014-04-28T14:36:55.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2014-04-28T15:10:02.000Z (almost 12 years ago)
- Last Synced: 2025-02-21T16:48:27.567Z (about 1 year ago)
- Topics: app-engine, google-appengine
- Language: Python
- Homepage:
- Size: 125 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
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()