How to use the pysyncobj.syncobj.replicated function in pysyncobj

To help you get started, we’ve selected a few pysyncobj examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bakwc / PySyncObj / pysyncobj / batteries.py View on Github external
    @replicated
    def sort(self, reverse=False):
        """Stable sort *IN PLACE*"""
        self.__data.sort(reverse=reverse)
github bakwc / PySyncObj / pysyncobj / batteries.py View on Github external
    @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
github bakwc / PySyncObj / pysyncobj / batteries.py View on Github external
    @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
github bakwc / PySyncObj / pysyncobj / batteries.py View on Github external
    @replicated
    def pop(self):
        """
        Remove and return an arbitrary set element.
        Raises KeyError if the set is empty.
        """
        return self.__data.pop()
github bakwc / PySyncObj / pysyncobj / batteries.py View on Github external
    @replicated
    def clear(self):
        """ Remove all elements from this set. """
        self.__data.clear()
github bakwc / PySyncObj / pysyncobj / batteries.py View on Github external
    @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)
github bakwc / PySyncObj / pysyncobj / batteries.py View on Github external
    @replicated
    def update(self, other):
        """ Update a set with the union of itself and others. """
        self.__data.update(other)
github bakwc / PySyncObj / pysyncobj / batteries.py View on Github external
    @replicated
    def __setitem__(self, key, value):
        """Set value for specified key"""
        self.__data[key] = value
github bakwc / PySyncObj / pysyncobj / batteries.py View on Github external
    @replicated
    def setdefault(self, key, default):
        """Return value for specified key, set default value if key not exist"""
        return self.__data.setdefault(key, default)
github bakwc / PySyncObj / pysyncobj / batteries.py View on Github external
    @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