@critsec and @debouncedcritsec for google app engine, python standard environment
Project description
# im_critsec
This library contains the decorator @critsec, for running a function as a critical section (non-reentrant task).
[![Build Status](https://travis-ci.org/emlynoregan/im_critsec.svg?branch=master)](https://travis-ci.org/emlynoregan/im_critsec)
## Install
Use the python package for this library. You can find the package online [here](https://pypi.org/project/im-critsec/).
Change to your Python App Engine project's root folder and do the following:
> pip install im_critsec --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).
## Usage
You'll need to have im_task set up correctly using either im_task_flask or im_task_webapp (or both!) depending on which framework you are using.
Then, you can run a function as a critical section as follows:
@critsec
def MyCriticalFunc():
# do some stuff that needs to not be interrupted
# this function will *never* run re-entrantly, even in other processes on other computers
MyCriticalFunc() # kicking off the call to it here.
Critsec forms a separate critical section for each combination of arguments and outer scope references. eg:
@critsec
def MyCriticalFunc(value):
# do some stuff that needs to not be interrupted
# this function will *never* run re-entrantly, even in other processes on other computers
MyCriticalFunc(1) # first call
MyCriticalFunc(1) # in same critical section as first call
MyCriticalFunc(2) # in a different critical section
## rerun_on_skip
When a critical section is entered, subsequent calls to the same critical section will be ignored while that critical section is running. However, those skipped calls are remembered. Once the critical section is finished, if any calls were skipped, then the critical section runs one more time. This is called rerun_on_skip.
If you would prefer not to have rerun_on_skip, you can turn it off:
@critsec(rerun_on_skip = False)
def ThisFunctionIsNotRerunOnSkip(value):
# do a thing
## @critsec is a form of @task
@critsec is exactly like @task; you can pass in task arguments, eg:
@critsec(queue = "myqueue")
def ThisFunctionRunsOnMyQueue():
# do a thing
This library contains the decorator @critsec, for running a function as a critical section (non-reentrant task).
[![Build Status](https://travis-ci.org/emlynoregan/im_critsec.svg?branch=master)](https://travis-ci.org/emlynoregan/im_critsec)
## Install
Use the python package for this library. You can find the package online [here](https://pypi.org/project/im-critsec/).
Change to your Python App Engine project's root folder and do the following:
> pip install im_critsec --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).
## Usage
You'll need to have im_task set up correctly using either im_task_flask or im_task_webapp (or both!) depending on which framework you are using.
Then, you can run a function as a critical section as follows:
@critsec
def MyCriticalFunc():
# do some stuff that needs to not be interrupted
# this function will *never* run re-entrantly, even in other processes on other computers
MyCriticalFunc() # kicking off the call to it here.
Critsec forms a separate critical section for each combination of arguments and outer scope references. eg:
@critsec
def MyCriticalFunc(value):
# do some stuff that needs to not be interrupted
# this function will *never* run re-entrantly, even in other processes on other computers
MyCriticalFunc(1) # first call
MyCriticalFunc(1) # in same critical section as first call
MyCriticalFunc(2) # in a different critical section
## rerun_on_skip
When a critical section is entered, subsequent calls to the same critical section will be ignored while that critical section is running. However, those skipped calls are remembered. Once the critical section is finished, if any calls were skipped, then the critical section runs one more time. This is called rerun_on_skip.
If you would prefer not to have rerun_on_skip, you can turn it off:
@critsec(rerun_on_skip = False)
def ThisFunctionIsNotRerunOnSkip(value):
# do a thing
## @critsec is a form of @task
@critsec is exactly like @task; you can pass in task arguments, eg:
@critsec(queue = "myqueue")
def ThisFunctionRunsOnMyQueue():
# do a thing
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
im_critsec-0.0.4.tar.gz
(3.9 kB
view details)
Built Distribution
File details
Details for the file im_critsec-0.0.4.tar.gz
.
File metadata
- Download URL: im_critsec-0.0.4.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 537527011e25b81624b8e654b9345e8c93158aeaa421232a0c63be0455a83880 |
|
MD5 | b1541bfae92d11a288033d464e7392e0 |
|
BLAKE2b-256 | bba9ae7cd2a83d31173632bebf3582493ced366d9e9e0f87fc77334ec4c19809 |
File details
Details for the file im_critsec-0.0.4-py2.py3-none-any.whl
.
File metadata
- Download URL: im_critsec-0.0.4-py2.py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68589b88dd1c7e73766987682a4a6ceeddda54db1c34a40f29361064e4e7f938 |
|
MD5 | b94bed26ed9ef25f0ccefe7175912d17 |
|
BLAKE2b-256 | 4753cbc1b463a1087fab6ada7ecd48f0056aaa87d1d09ada8dcd6df2da6c1c0e |