mirror of
https://github.com/progval/Limnoria.git
synced 2025-04-26 04:51:06 -05:00
utils/structures: Fix typos, remove unused code
This commit is contained in:
parent
8053d74e71
commit
3f77c53ed5
@ -466,9 +466,9 @@ class ExpiringDict(collections.abc.MutableMapping):
|
|||||||
For guaranteed expiry, use TimeoutDict.
|
For guaranteed expiry, use TimeoutDict.
|
||||||
|
|
||||||
Currently, this is implemented by internally alternating two "generation"
|
Currently, this is implemented by internally alternating two "generation"
|
||||||
dicts, which are dropped after a certain time."""
|
dicts, which are dropped after a certain time.
|
||||||
|
"""
|
||||||
__slots__ = ('_lock', 'old_gen', 'new_gen', 'timeout', '_last_switch')
|
__slots__ = ('_lock', 'old_gen', 'new_gen', 'timeout', '_last_switch')
|
||||||
__synchronized__ = ('_expire_generations',)
|
|
||||||
|
|
||||||
def __init__(self, timeout, items=None):
|
def __init__(self, timeout, items=None):
|
||||||
self._lock = threading.Lock()
|
self._lock = threading.Lock()
|
||||||
@ -488,7 +488,7 @@ class ExpiringDict(collections.abc.MutableMapping):
|
|||||||
# Check the new_gen first, as it contains the most recent
|
# Check the new_gen first, as it contains the most recent
|
||||||
# insertion.
|
# insertion.
|
||||||
# We must also check them in this order to be thread-safe when
|
# We must also check them in this order to be thread-safe when
|
||||||
# _expire_generations() runs.
|
# _expireGenerations() runs.
|
||||||
return self.new_gen[key]
|
return self.new_gen[key]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
try:
|
try:
|
||||||
@ -498,7 +498,7 @@ class ExpiringDict(collections.abc.MutableMapping):
|
|||||||
|
|
||||||
def __contains__(self, key):
|
def __contains__(self, key):
|
||||||
# the two clauses must be in this order to be thread-safe when
|
# the two clauses must be in this order to be thread-safe when
|
||||||
# _expire_generations() runs.
|
# _expireGenerations() runs.
|
||||||
return key in self.new_gen or key in self.old_gen
|
return key in self.new_gen or key in self.old_gen
|
||||||
|
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
@ -545,7 +545,6 @@ class TimeoutDict: # Don't inherit from MutableMapping: not thread-safe
|
|||||||
guaranteed timeout.
|
guaranteed timeout.
|
||||||
"""
|
"""
|
||||||
__slots__ = ('_lock', 'd', 'timeout')
|
__slots__ = ('_lock', 'd', 'timeout')
|
||||||
__synchronized__ = ('_expire_generations',)
|
|
||||||
|
|
||||||
def __init__(self, timeout, items=None):
|
def __init__(self, timeout, items=None):
|
||||||
expiry = time.time() + timeout
|
expiry = time.time() + timeout
|
||||||
|
Loading…
x
Reference in New Issue
Block a user