Esempio n. 1
0
    def get_state(self):
        '''Get the current state of Bartendro'''

        # If we're not running inside uwsgi, then we can't keep global state
        if not have_uwsgi: return self.state

        uwsgi.lock()
        state = uwsgi.sharedarea_read8(0, 1)
        uwsgi.unlock()

        return state
Esempio n. 2
0
    def get_state(self):
        '''Get the current state of Bartendro'''

        # If we're not running inside uwsgi, then we can't keep global state
        if not have_uwsgi: return self.state

        uwsgi.lock()
        state = uwsgi.sharedarea_read8(0, 1)
        uwsgi.unlock()

        return state
Esempio n. 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_read8(0, 0)
        if not is_locked:
           uwsgi.unlock()
           return False
        uwsgi.sharedarea_write8(0, 0, 0)
        uwsgi.unlock()

        return True
Esempio n. 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_read8(0, 0)
        if not is_locked:
            uwsgi.unlock()
            return False
        uwsgi.sharedarea_write8(0, 0, 0)
        uwsgi.unlock()

        return True
Esempio n. 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_read8(0, 0)
        if is_locked:
           uwsgi.unlock()
           return False
        uwsgi.sharedarea_write8(0, 0, 1)
        uwsgi.unlock()

        return True
Esempio n. 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_read8(0, 0)
        if is_locked:
            uwsgi.unlock()
            return False
        uwsgi.sharedarea_write8(0, 0, 1)
        uwsgi.unlock()

        return True