Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@replicated
def sort(self, reverse=False):
"""Stable sort *IN PLACE*"""
self.__data.sort(reverse=reverse)
@replicated
def add(self, value):
"""
Adds value to a counter.
:param value: value to add
:return: new counter value
"""
self.__counter += value
return self.__counter
@replicated
def put(self, item):
"""Put an item into the queue.
True - if item placed in queue.
False - if queue is full and item can not be placed."""
if self.__maxsize and len(self.__data) >= self.__maxsize:
return False
self.__data.append(item)
return True
@replicated
def pop(self):
"""
Remove and return an arbitrary set element.
Raises KeyError if the set is empty.
"""
return self.__data.pop()
@replicated
def clear(self):
""" Remove all elements from this set. """
self.__data.clear()
@replicated
def prolongate(self, clientID, currentTime):
for lockID in list(self.__locks):
lockClientID, lockTime = self.__locks[lockID]
if currentTime - lockTime > self.__autoUnlockTime:
del self.__locks[lockID]
continue
if lockClientID == clientID:
self.__locks[lockID] = (clientID, currentTime)
@replicated
def update(self, other):
""" Update a set with the union of itself and others. """
self.__data.update(other)
@replicated
def __setitem__(self, key, value):
"""Set value for specified key"""
self.__data[key] = value
@replicated
def setdefault(self, key, default):
"""Return value for specified key, set default value if key not exist"""
return self.__data.setdefault(key, default)
@replicated
def sub(self, value):
"""
Subtracts a value from counter.
:param value: value to subtract
:return: new counter value
"""
self.__counter -= value
return self.__counter