Package flickrapi :: Module tokencache :: Class LockingTokenCache
[hide private]
[frames] | no frames]

Class LockingTokenCache

source code

object --+    
         |    
TokenCache --+
             |
            LockingTokenCache

Locks the token cache when reading or updating it, so that multiple processes can safely use the same API key.
Instance Methods [hide private]
 
get_lock_name(self)
Returns the filename of the lock.
source code
 
get_pidfile_name(self)
Returns the name of the pidfile in the lock directory.
source code
 
get_lock_pid(self)
Returns the PID that is stored in the lock directory, or None if there is no such file.
source code
 
acquire(self, timeout=60)
Locks the token cache for this key and username.
source code
 
release(self)
Unlocks the token cache for this key.
source code
 
__del__(self)
Cleans up any existing lock.
source code
 
locked(method)
Decorator, ensures the method runs in a locked cache.
source code
 
get_cached_token(self, *args, **kwargs)
Read and return a cached token, or None if not found.
source code
 
set_cached_token(self, *args, **kwargs)
Cache a token for later use.
source code
 
forget(self, *args, **kwargs)
Removes the cached token
source code

Inherited from TokenCache: __init__, get_cached_token_filename, get_cached_token_path

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]
  lock
Returns the filename of the lock.
  pidfile_name
Returns the name of the pidfile in the lock directory.
  token
The cached token

Inherited from object: __class__

Method Details [hide private]

acquire(self, timeout=60)

source code 

Locks the token cache for this key and username.

If the token cache is already locked, waits until it is released. Throws an exception when the lock cannot be acquired after timeout seconds.

get_cached_token(self, *args, **kwargs)

source code 

Read and return a cached token, or None if not found.

The token is read from the cached token file.

Decorators:
  • @locked
Overrides: TokenCache.get_cached_token

set_cached_token(self, *args, **kwargs)

source code 
Cache a token for later use.
Decorators:
  • @locked
Overrides: TokenCache.set_cached_token

forget(self, *args, **kwargs)

source code 
Removes the cached token
Decorators:
  • @locked
Overrides: TokenCache.forget

Property Details [hide private]

lock

Returns the filename of the lock.
Get Method:
get_lock_name(self) - Returns the filename of the lock.

pidfile_name

Returns the name of the pidfile in the lock directory.
Get Method:
get_pidfile_name(self) - Returns the name of the pidfile in the lock directory.

token

The cached token
Get Method:
get_cached_token(self, *args, **kwargs) - Read and return a cached token, or None if not found.
Set Method:
set_cached_token(self, *args, **kwargs) - Cache a token for later use.
Delete Method:
forget(self, *args, **kwargs) - Removes the cached token