diff options
author | CoprDistGit <infra@openeuler.org> | 2023-05-05 10:52:13 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-05-05 10:52:13 +0000 |
commit | ea1f7dc2f8f32f57019d5028aeb4ad90bea5aaa1 (patch) | |
tree | 893cd9ccaedf8e5fd4acde857c30f19265d5ec06 | |
parent | 149ad27725d77ca6a8fa76f6a2a56c6cc02afac7 (diff) |
automatic import of python-appenginetaskutilsopeneuler20.03
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-appenginetaskutils.spec | 466 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 468 insertions, 0 deletions
@@ -0,0 +1 @@ +/appenginetaskutils-0.4.3.tar.gz diff --git a/python-appenginetaskutils.spec b/python-appenginetaskutils.spec new file mode 100644 index 0000000..8744ee9 --- /dev/null +++ b/python-appenginetaskutils.spec @@ -0,0 +1,466 @@ +%global _empty_manifest_terminate_build 0 +Name: python-appenginetaskutils +Version: 0.4.3 +Release: 1 +Summary: Utilities for using appengine tasks. Inspired by deferred. +License: LICENSE.txt +URL: https://github.com/emlynoregan/appenginetaskutils +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/6e/76/903589a1ce16df307c3c9eba314db3fd31a9dd41bad95e6ec5ecbf28cbeb/appenginetaskutils-0.4.3.tar.gz +BuildArch: noarch + +Requires: python3-GoogleAppEngineCloudStorageClient +Requires: python3-Werkzeug +Requires: python3-cloudpickle +Requires: python3-google-cloud-storage + +%description +# appenginetaskutils +This is the repo for the appengine task utils library. It generates the appenginetaskutils package + +## Install + +Use the python package for this library. You can find the package online [here](https://pypi.python.org/pypi/appenginetaskutils). + +Change to your Python App Engine project's root folder and do the following: + +> pip install appenginetaskutils --target lib + +Or add it to your requirements.txt. You'll also need to set up vendoring, see [app engine vendoring instructions here](https://cloud.google.com/appengine/docs/python/tools/using-libraries-python-27). + +## @task + +The most basic element of the taskutils library is task(). This decorator function is designed to be used as a replacement for [deferred](https://cloud.google.com/appengine/articles/deferred). + +### Configuring @task + +When using deferred you have a builtin to configure in app.yaml to make it work. For taskutils.task, you need to add the following to your app.yaml and/or \<servicename\>.yaml file: + + handlers: + - url: /_ah/task/.* + script: taskutils.app + login: admin + +This rule creates a generic handler for task to defer work to background push tasks. + +Add it at the top of the list (to make sure other rules don't override it). + +### Importing task + +You can import task into your modules like this: + + from taskutils import task + +### Using task as a decorator + +You can take any function and make it run in a separate task, like this: + + @task + def myfunction(): + ... do stuff ... + +Just call the function normally, eg: + + myfunction() + +You can use @task on any function, including nested functions, recursive functions, recursive nested functions, the sky is the limit. This is possible because of use of [yccloudpickle](https://medium.com/the-infinite-machine/python-function-serialisation-with-yccloudpickle-b2ff6b2ad5da#.zei3n0ibu) as the underlying serialisation library. + +Your function can also have arguments, including other functions: + + def myouterfunction(mapf): + + @task + def myinnerfunction(objects): + for object in objects: + mapf(object) + + ...get some list of lists of objects... + for objects in objectslist: + myinnerfunction(objects) + + def dosomethingwithobject(object): + ... do something with an object ... + + myouterfunction(dosomethingwithobject) + +The functions and arguments are being serialised and deserialised for you behind the scenes. + +When enqueuing a background task, the App Engine Task and TaskQueue libraries can take a set of parameters. You can pass these to the decorator: + + @task(queue="myqueue", countdown=5) + def anotherfunction(): + ... do stuff ... + +Details of the arguments allowed to Tasks are available [here](https://cloud.google.com/appengine/docs/python/refdocs/google.appengine.api.taskqueue), under **class google.appengine.api.taskqueue.Task(payload=None, \*\*kwargs)**. The task decorator supports a couple of extra ones, detailed below. + +### Using task as a factory + +You can also use task to decorate a function on the fly, like this: + + def somefunction(a, b): + ... does something ... + + somefunctionintask = task(somefunction, queue="myqueue") + +Then you can call the function returned by task when you are ready: + + somefunctionintask(1, 2) + +You could do both of these steps at once, too: + + + task(somefunction, queue="myqueue")(1, 2) + +### transactional + +Pass transactional=True to have your [task launch transactionally](https://cloud.google.com/appengine/docs/python/datastore/transactions#transactional_task_enqueuing). eg: + + @task(transactional=True) + def myserioustransactionaltask(): + ... + +### includeheaders + +If you'd like access to headers in your function (a dictionary of headers passed to your task, it's a web request after all), set includeheaders=True in your call to @task. You'll also need to accept the headers argument in your function. + + @task(includeheaders=True) + def myfunctionwithheaders(amount, headers): + ... stuff ... + + myfunctionwithheaders(10) + +App Engine passes useful information to your task in headers, for example X-Appengine-TaskRetryCount. + +### other bits + +When using deferred, all your calls are logged as /_ah/queue/deferred. But @task uses a url of the form /_ah/task/\<module\>/\<function\>, eg: + + /_ah/task/mymodule/somefunction + +which makes debugging a lot easier. + + + + + + + + + +%package -n python3-appenginetaskutils +Summary: Utilities for using appengine tasks. Inspired by deferred. +Provides: python-appenginetaskutils +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-appenginetaskutils +# appenginetaskutils +This is the repo for the appengine task utils library. It generates the appenginetaskutils package + +## Install + +Use the python package for this library. You can find the package online [here](https://pypi.python.org/pypi/appenginetaskutils). + +Change to your Python App Engine project's root folder and do the following: + +> pip install appenginetaskutils --target lib + +Or add it to your requirements.txt. You'll also need to set up vendoring, see [app engine vendoring instructions here](https://cloud.google.com/appengine/docs/python/tools/using-libraries-python-27). + +## @task + +The most basic element of the taskutils library is task(). This decorator function is designed to be used as a replacement for [deferred](https://cloud.google.com/appengine/articles/deferred). + +### Configuring @task + +When using deferred you have a builtin to configure in app.yaml to make it work. For taskutils.task, you need to add the following to your app.yaml and/or \<servicename\>.yaml file: + + handlers: + - url: /_ah/task/.* + script: taskutils.app + login: admin + +This rule creates a generic handler for task to defer work to background push tasks. + +Add it at the top of the list (to make sure other rules don't override it). + +### Importing task + +You can import task into your modules like this: + + from taskutils import task + +### Using task as a decorator + +You can take any function and make it run in a separate task, like this: + + @task + def myfunction(): + ... do stuff ... + +Just call the function normally, eg: + + myfunction() + +You can use @task on any function, including nested functions, recursive functions, recursive nested functions, the sky is the limit. This is possible because of use of [yccloudpickle](https://medium.com/the-infinite-machine/python-function-serialisation-with-yccloudpickle-b2ff6b2ad5da#.zei3n0ibu) as the underlying serialisation library. + +Your function can also have arguments, including other functions: + + def myouterfunction(mapf): + + @task + def myinnerfunction(objects): + for object in objects: + mapf(object) + + ...get some list of lists of objects... + for objects in objectslist: + myinnerfunction(objects) + + def dosomethingwithobject(object): + ... do something with an object ... + + myouterfunction(dosomethingwithobject) + +The functions and arguments are being serialised and deserialised for you behind the scenes. + +When enqueuing a background task, the App Engine Task and TaskQueue libraries can take a set of parameters. You can pass these to the decorator: + + @task(queue="myqueue", countdown=5) + def anotherfunction(): + ... do stuff ... + +Details of the arguments allowed to Tasks are available [here](https://cloud.google.com/appengine/docs/python/refdocs/google.appengine.api.taskqueue), under **class google.appengine.api.taskqueue.Task(payload=None, \*\*kwargs)**. The task decorator supports a couple of extra ones, detailed below. + +### Using task as a factory + +You can also use task to decorate a function on the fly, like this: + + def somefunction(a, b): + ... does something ... + + somefunctionintask = task(somefunction, queue="myqueue") + +Then you can call the function returned by task when you are ready: + + somefunctionintask(1, 2) + +You could do both of these steps at once, too: + + + task(somefunction, queue="myqueue")(1, 2) + +### transactional + +Pass transactional=True to have your [task launch transactionally](https://cloud.google.com/appengine/docs/python/datastore/transactions#transactional_task_enqueuing). eg: + + @task(transactional=True) + def myserioustransactionaltask(): + ... + +### includeheaders + +If you'd like access to headers in your function (a dictionary of headers passed to your task, it's a web request after all), set includeheaders=True in your call to @task. You'll also need to accept the headers argument in your function. + + @task(includeheaders=True) + def myfunctionwithheaders(amount, headers): + ... stuff ... + + myfunctionwithheaders(10) + +App Engine passes useful information to your task in headers, for example X-Appengine-TaskRetryCount. + +### other bits + +When using deferred, all your calls are logged as /_ah/queue/deferred. But @task uses a url of the form /_ah/task/\<module\>/\<function\>, eg: + + /_ah/task/mymodule/somefunction + +which makes debugging a lot easier. + + + + + + + + + +%package help +Summary: Development documents and examples for appenginetaskutils +Provides: python3-appenginetaskutils-doc +%description help +# appenginetaskutils +This is the repo for the appengine task utils library. It generates the appenginetaskutils package + +## Install + +Use the python package for this library. You can find the package online [here](https://pypi.python.org/pypi/appenginetaskutils). + +Change to your Python App Engine project's root folder and do the following: + +> pip install appenginetaskutils --target lib + +Or add it to your requirements.txt. You'll also need to set up vendoring, see [app engine vendoring instructions here](https://cloud.google.com/appengine/docs/python/tools/using-libraries-python-27). + +## @task + +The most basic element of the taskutils library is task(). This decorator function is designed to be used as a replacement for [deferred](https://cloud.google.com/appengine/articles/deferred). + +### Configuring @task + +When using deferred you have a builtin to configure in app.yaml to make it work. For taskutils.task, you need to add the following to your app.yaml and/or \<servicename\>.yaml file: + + handlers: + - url: /_ah/task/.* + script: taskutils.app + login: admin + +This rule creates a generic handler for task to defer work to background push tasks. + +Add it at the top of the list (to make sure other rules don't override it). + +### Importing task + +You can import task into your modules like this: + + from taskutils import task + +### Using task as a decorator + +You can take any function and make it run in a separate task, like this: + + @task + def myfunction(): + ... do stuff ... + +Just call the function normally, eg: + + myfunction() + +You can use @task on any function, including nested functions, recursive functions, recursive nested functions, the sky is the limit. This is possible because of use of [yccloudpickle](https://medium.com/the-infinite-machine/python-function-serialisation-with-yccloudpickle-b2ff6b2ad5da#.zei3n0ibu) as the underlying serialisation library. + +Your function can also have arguments, including other functions: + + def myouterfunction(mapf): + + @task + def myinnerfunction(objects): + for object in objects: + mapf(object) + + ...get some list of lists of objects... + for objects in objectslist: + myinnerfunction(objects) + + def dosomethingwithobject(object): + ... do something with an object ... + + myouterfunction(dosomethingwithobject) + +The functions and arguments are being serialised and deserialised for you behind the scenes. + +When enqueuing a background task, the App Engine Task and TaskQueue libraries can take a set of parameters. You can pass these to the decorator: + + @task(queue="myqueue", countdown=5) + def anotherfunction(): + ... do stuff ... + +Details of the arguments allowed to Tasks are available [here](https://cloud.google.com/appengine/docs/python/refdocs/google.appengine.api.taskqueue), under **class google.appengine.api.taskqueue.Task(payload=None, \*\*kwargs)**. The task decorator supports a couple of extra ones, detailed below. + +### Using task as a factory + +You can also use task to decorate a function on the fly, like this: + + def somefunction(a, b): + ... does something ... + + somefunctionintask = task(somefunction, queue="myqueue") + +Then you can call the function returned by task when you are ready: + + somefunctionintask(1, 2) + +You could do both of these steps at once, too: + + + task(somefunction, queue="myqueue")(1, 2) + +### transactional + +Pass transactional=True to have your [task launch transactionally](https://cloud.google.com/appengine/docs/python/datastore/transactions#transactional_task_enqueuing). eg: + + @task(transactional=True) + def myserioustransactionaltask(): + ... + +### includeheaders + +If you'd like access to headers in your function (a dictionary of headers passed to your task, it's a web request after all), set includeheaders=True in your call to @task. You'll also need to accept the headers argument in your function. + + @task(includeheaders=True) + def myfunctionwithheaders(amount, headers): + ... stuff ... + + myfunctionwithheaders(10) + +App Engine passes useful information to your task in headers, for example X-Appengine-TaskRetryCount. + +### other bits + +When using deferred, all your calls are logged as /_ah/queue/deferred. But @task uses a url of the form /_ah/task/\<module\>/\<function\>, eg: + + /_ah/task/mymodule/somefunction + +which makes debugging a lot easier. + + + + + + + + + +%prep +%autosetup -n appenginetaskutils-0.4.3 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-appenginetaskutils -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 0.4.3-1 +- Package Spec generated @@ -0,0 +1 @@ +1650907ca80c2c56346466e08d9f1ca2 appenginetaskutils-0.4.3.tar.gz |