def lock_context(self, timeout='default', requested_key='exclusive'):
        """A context that locks

        :param timeout: Absolute time period (in milliseconds) that a resource
                        waits to get unlocked by the locking session before
                        returning an error. (Defaults to self.timeout)
        :param requested_key: When using default of 'exclusive' the lock
                              is an exclusive lock.
                              Otherwise it is the access key for the shared lock or
                              None to generate a new shared access key.

        The returned context is the access_key if applicable.

        """
        if requested_key == 'exclusive':
            self.lock_excl(timeout)
            access_key = None
        else:
            access_key = self.lock(timeout, requested_key)
        try:
            yield access_key
        finally:
            self.unlock()
def lock_context ( self , timeout = 'default' , requested_key = 'exclusive' ) : if requested_key == 'exclusive' : self . lock_excl ( timeout ) access_key = None else : access_key = self . lock ( timeout , requested_key ) try : yield access_key finally : self . unlock ( )
A context that locks

        :param timeout: Absolute time period (in milliseconds) that a resource
                        waits to get unlocked by the locking session before
                        returning an error. (Defaults to self.timeout)
        :param requested_key: When using default of 'exclusive' the lock
                              is an exclusive lock.
                              Otherwise it is the access key for the shared lock or
                              None to generate a new shared access key.

        The returned context is the access_key if applicable.