示例#1
0
    def set_state(self, state):
        """Set the current state of Bartendro"""

        # If we're not running inside uwsgi, then don't try to use the lock
        if not have_uwsgi: return

        uwsgi.lock()
        uwsgi.sharedarea_writebyte(1, state)
        uwsgi.unlock()

        return True
示例#2
0
    def set_state(self, state):
        """Set the current state of Bartendro"""

        # If we're not running inside uwsgi, then don't try to use the lock
        if not have_uwsgi: return

        uwsgi.lock()
        uwsgi.sharedarea_writebyte(1, state)
        uwsgi.unlock()

        return True
示例#3
0
    def unlock_bartendro(self):
        """Call this function when you've previously locked bartendro and now you want to unlock it."""

        # If we're not running inside uwsgi, then don't try to use the lock
        if not have_uwsgi: return True

        uwsgi.lock()
        is_locked = uwsgi.sharedarea_readbyte(0)
        if not is_locked:
            uwsgi.unlock()
            return False
        uwsgi.sharedarea_writebyte(0, 0)
        uwsgi.unlock()

        return True
示例#4
0
    def unlock_bartendro(self):
        """Call this function when you've previously locked bartendro and now you want to unlock it."""

        # If we're not running inside uwsgi, then don't try to use the lock
        if not have_uwsgi: return True

        uwsgi.lock()
        is_locked = uwsgi.sharedarea_readbyte(0)
        if not is_locked:
           uwsgi.unlock()
           return False
        uwsgi.sharedarea_writebyte(0, 0)
        uwsgi.unlock()

        return True
示例#5
0
    def lock_bartendro(self):
        """Call this function before making a drink or doing anything that where two users' action may conflict.
           This function will return True if the lock was granted, of False is someone else has already locked 
           Bartendro."""

        # If we're not running inside uwsgi, then don't try to use the lock
        if not have_uwsgi: return True

        uwsgi.lock()
        is_locked = uwsgi.sharedarea_readbyte(0)
        if is_locked:
            uwsgi.unlock()
            return False
        uwsgi.sharedarea_writebyte(0, 1)
        uwsgi.unlock()

        return True
示例#6
0
    def lock_bartendro(self):
        """Call this function before making a drink or doing anything that where two users' action may conflict.
           This function will return True if the lock was granted, of False is someone else has already locked 
           Bartendro."""

        # If we're not running inside uwsgi, then don't try to use the lock
        if not have_uwsgi: return True

        uwsgi.lock()
        is_locked = uwsgi.sharedarea_readbyte(0)
        if is_locked:
           uwsgi.unlock()
           return False
        uwsgi.sharedarea_writebyte(0, 1)
        uwsgi.unlock()

        return True