class documentation

class CriticalSection(object):

Constructor: CriticalSection(id, state, timeout)

View In Hierarchy

Context manager to guard a critical resource path.

Method __enter__ Enter the critical section.
Method __exit__ Exit the critical section.
Method __init__ Initialization of the context manager.
Instance Variable id Resource ID of the resource to be monitored.
Instance Variable state State of the resource.
Instance Variable timeout Timeout for waiting for the critical section.
def __enter__(self):

Enter the critical section.

def __exit__(self, exctype: type[BaseException] | None, excinst: BaseException | None, exctb: TracebackType | None) -> bool | None:

Exit the critical section.

Parameters
exctype:type[BaseException] | NoneException type
excinst:BaseException | NoneException instance
exctb:TracebackType | NoneException traceback
Returns
bool | NoneAlways None
def __init__(self, id: str, state: str | None = '', timeout: float | None = None):

Initialization of the context manager.

Parameters
id:strResource ID of the resource to be monitored. This may also be any other ID in cases where the critical section is not a resource.
state:str | NoneState of the resource.
timeout:float | NoneTimeout for waiting for the critical section. A timeout of 0.0 times out immediately.
id =

Resource ID of the resource to be monitored.

state =

State of the resource.

timeout =

Timeout for waiting for the critical section.