-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 17d433f
Showing
11 changed files
with
792 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Copyright (c) 2012, by Herrn Kaste | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
|
||
1. Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials | ||
provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include LICENSE README.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
A convenience module on top of the deferred library that comes with the Google AppEngine (GAE). | ||
|
||
Note that you have to enable the deferred library in your app.yaml | ||
|
||
:: | ||
|
||
builtins: | ||
- deferred: on | ||
|
||
In a nutshell:: | ||
|
||
from waterf import queue, task | ||
|
||
queue.inorder( | ||
task(check_condition), | ||
queue.parallel( | ||
task(remove, id=101), | ||
task(remove, id=102), | ||
task(remove, id=103) | ||
), | ||
task(email, to='foo@bar.com') | ||
).run() | ||
|
||
Should be pretty self-explanatory: it first runs the function ``check_condition``, then it runs the function ``remove`` three times in parallel, after that it runs ``email``. | ||
|
||
To abort execution of a series you either raise ``queue.PermanentTaskFailure`` or as a convenience return ``queue.ABORT``. | ||
|
||
You use ``task()`` exactly the same as you used ``deferred.defer()``:: | ||
|
||
task(check, id=102, _countdown=20) | ||
task(email, to='foo@bar.com', _queue='mailer') | ||
|
||
After constructing a task you either ``run()`` or ``enqueue()`` it; whereby:: | ||
|
||
task(foo, 'bar').enqueue() <==> deferred.defer(foo, 'bar') | ||
task(foo, 'bar').run() <==> foo('bar') | ||
|
||
Read the tests. Thank you. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import os, re | ||
from setuptools import setup, find_packages | ||
|
||
def _read_contents(fn): | ||
here = os.path.dirname( os.path.realpath(__file__) ) | ||
filename = os.path.join(here, fn) | ||
with open(filename) as file: | ||
return file.read() | ||
|
||
version = re.findall(r'__version__ = "(.*?)"', _read_contents("waterf/__init__.py"))[0] | ||
|
||
setup( | ||
name='waterf', | ||
version=version, | ||
description="Chaining tasks on Google Appengine's (GAE) taskqueue.", | ||
long_description=_read_contents('README.rst'), | ||
author="herr kaste", | ||
author_email="herr.kaste@gmail.com", | ||
license="BSD", | ||
url='http://github.com/kaste/waterf', | ||
download_url='http://github.com/kaste/waterf/tarball/master#egg=waterf-dev', | ||
packages=find_packages(exclude=['tests']), | ||
install_requires=[], | ||
tests_require=['pytest'], | ||
keywords="google appengine gae taskqueue deferred", | ||
classifiers=[ | ||
'Development Status :: 4 - Beta', | ||
'Environment :: Web Environment', | ||
'Intended Audience :: Developers', | ||
'License :: OSI Approved :: BSD License', | ||
'Operating System :: OS Independent', | ||
'Programming Language :: Python', | ||
'Topic :: Internet :: WWW/HTTP', | ||
'Topic :: Software Development :: Libraries', | ||
], | ||
) | ||
|
||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import sys, os | ||
|
||
APP_ROOT = os.path.realpath(__file__) | ||
GAESDK_PATH = "c:\dev\gae" | ||
|
||
def fix_sys_path(path): | ||
sys.path.insert(0, path) | ||
|
||
import dev_appserver | ||
dev_appserver.fix_sys_path() | ||
|
||
def pytest_addoption(parser): | ||
group = parser.getgroup("gae", "google app engine plugin") | ||
group.addoption('--gaesdk', action='store', dest='gaesdk_path', | ||
metavar='PATH', default="c:\dev\gae", | ||
help="Google App Engine's root PATH") | ||
|
||
def pytest_configure(config): | ||
fix_sys_path(config.option.gaesdk_path) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import conftest | ||
|
||
|
||
def pytest_funcarg__taskqueue(request): | ||
from google.appengine.ext import testbed | ||
bed = request.getfuncargvalue('bed') | ||
bed.init_taskqueue_stub(root_path=conftest.APP_ROOT) | ||
return bed.get_stub(testbed.TASKQUEUE_SERVICE_NAME) | ||
|
||
def pytest_funcarg__ndb(request): | ||
from google.appengine.datastore import datastore_stub_util | ||
bed = request.getfuncargvalue('bed') | ||
bed.init_memcache_stub() | ||
policy = datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=0) | ||
bed.init_datastore_v3_stub(consistency_policy=policy) | ||
|
||
from google.appengine.ext import ndb | ||
return ndb | ||
|
||
def pytest_funcarg__fastndb(request): | ||
from google.appengine.datastore import datastore_stub_util | ||
bed = request.getfuncargvalue('bed') | ||
bed.init_memcache_stub() | ||
policy = datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=1) | ||
bed.init_datastore_v3_stub(consistency_policy=policy) | ||
|
||
from google.appengine.ext import ndb | ||
return ndb | ||
|
||
|
||
|
||
def pytest_funcarg__bed(request): | ||
from google.appengine.ext import testbed | ||
bed = testbed.Testbed() | ||
bed.activate() | ||
request.addfinalizer(lambda: teardown_bed(bed)) | ||
return bed | ||
|
||
def teardown_bed(bed): | ||
bed.deactivate() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
queue: | ||
- name: other | ||
rate: 5/s |
Oops, something went wrong.