Skip to main content
# 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


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)

Source distribution for im-critsec 0.0.4
File Size Uploaded
im_critsec-0.0.4.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for im-critsec 0.0.4
File Interpreter ABI Platform
im_critsec-0.0.4-py2.py3-none-any.whl Python 2, Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page