This library contains the decorator @critsec, for running a function as a critical section (non-reentrant task).
[](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
Metadata
Release files for im-critsec 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| im_critsec-0.0.4.tar.gz | 3.9 kB | Without provenance | Details for im_critsec-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| im_critsec-0.0.4-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for im_critsec-0.0.4-py2.py3-none-any.whl |
Total release size: 9.9 kB
Release files / im_critsec-0.0.4.tar.gz
| Download URL | im_critsec-0.0.4.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
537527011e25b81624b8e654b9345e8c93158aeaa421232a0c63be0455a83880
|
|
BLAKE2b-256 checksum How to use checksums |
bba9ae7cd2a83d31173632bebf3582493ced366d9e9e0f87fc77334ec4c19809
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / im_critsec-0.0.4-py2.py3-none-any.whl
| Download URL | im_critsec-0.0.4-py2.py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
68589b88dd1c7e73766987682a4a6ceeddda54db1c34a40f29361064e4e7f938
|
|
BLAKE2b-256 checksum How to use checksums |
4753cbc1b463a1087fab6ada7ecd48f0056aaa87d1d09ada8dcd6df2da6c1c0e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for im-critsec 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.