HappyDoc Generated Documentation unidist/sharedstate.py

unidist / sharedstate.py 

sharedstate

Shared State module. Get access to shared state.

All state has a namespace, and then the state id. sharecounter is used to procure new state ids, so it can be incremented atomically and shared with other procblock programs.

TODO(g): Implement serialization, archiving, snapshotting, and replication to sharestate. This will allow us flexibility in many things. This is not necessarily going to be the best scaling solution, but it will work and provide a way to keep state and distribute. Name spaces should have this specified individually. If not specified, state will not be archived, serialized, snapshotted or replicated.

  • Use the "archive" and "snapshot" modules for this, so archival and snapshotting is universal. Ensure a process restart will do the right thing in attempting to restore from snapshot, then archive, if present.

    TODO(g): Merge achive and snapshot. They are the same technology. If we really want to keep state, then we must archive each transactions and snapshot to avoid having to replay too many archives.

Functions   
  SetIfDoesntExist 
SetIfDoesntExist (
        bucket,
        key,
        value,
        )

Returns boolean, whether the value was set or not.

Args: bucket: string, name of bucket for state variables key: string or any, key to store data against. Any valid dict key. value: any, any object to be stored in shared state

  Set 
Set (
        bucket,
        key,
        value,
        )

Lock the shared control access to locks. This way we can safely acquire an individual lock or create a new lock without a race condition.

Args: bucket: string, name of bucket for state variables key: string or any, key to store data against. Any valid dict key. value: any, any object to be stored in shared state

  _EnsureBucketExists 
_EnsureBucketExists ( bucket )
  Get 
Get (
        bucket,
        key,
        default=StateKeyNotFound,
        )

Lock the shared control access to locks. This way we can safely acquire an individual lock or create a new lock without a race condition.

Args: bucket: string, name of bucket for state variables key: string or any, key to store data against. Any valid dict key. default: any value (optional), if set and there is no data in this key, then this value will be set in the key and returned.

Exceptions   

StateBucketDoesntExist( 'Bucket doesnt exist: %s' % bucket )

  BucketExists 
BucketExists ( bucket )

A bucket exists.

Args: bucket: string, name of bucket for state variables

  _LockState 
_LockState ( bucket )
  _UnlockState 
_UnlockState ( bucket )
Exceptions   

StateDoesntExist( 'Not found: %s' % bucket )

  GetBucketKeys 
GetBucketKeys ( bucket )

Returns the keys in a bucket.

Args: bucket: string, name of bucket for state variables

NOTE(g): Having a "GetKeys()" function is rejected, due to it being confusing.

Exceptions   

StateBucketDoesntExist( 'Bucket doesnt exist: %s' % bucket )

  GetSet 
GetSet (
        bucket,
        key,
        value,
        )

Returns boolean if this named lock is locked. If doesnt exist, still False

Args: bucket: string, name of bucket for state variables key: string or any, key to store data against. Any valid dict key. value: any, any object to be stored in shared state

  KeyExists 
KeyExists ( bucket,  key )

A key exists inside a bucket.

Args: bucket: string, name of bucket for state variables key: string or any, key to store data against. Any valid dict key.

Exceptions   

StateBucketDoesntExist( 'Bucket doesnt exist: %s' % bucket )

Classes   

StateBucketNotFound

This state bucket was not found. Different than it having a value of None.

StateKeyNotFound

This state key was not found. Different than it having a value of None.

StateBucketDoesntExist

This state bucket does not exist, so it cannot by returned.


This document was automatically generated Tue Aug 17 15:20:25 2010 by HappyDoc version 3.1