narupa.utilities.key_lockable_map module¶
Module providing an implementation of a dictionary-like object that can be locked during access to provide a way for asynchronous clients to edit the contents in a thread-safe manner.
-
class
narupa.utilities.key_lockable_map.
KeyLockableMap
¶ Bases:
object
Module providing an implementation of a dictionary-object that can be locked during access to provide a way for asynchronous clients to edit the contents in a thread-safe manner.
-
delete
(owner_id, key)¶
-
get
(resource_id, default=None)¶
-
get_all
()¶
-
lock_key
(owner_id, key, duration=None)¶
-
player_can_lock_key
(player_id, key)¶
-
release_key
(owner_id, key)¶
-
remove_owner
(owner_id)¶
-
set
(owner_id, key, value)¶
-
set_no_replace
(key, value)¶ Sets a value with the given key, subject to the constraint that the key must not already exist.
Parameters: - key – Key to register value with.
- value – Value to set.
Raises: KeyError – If the key already exists.
-
-
exception
narupa.utilities.key_lockable_map.
ResourceLockedError
¶ Bases:
Exception