def refresh(self, token, timeout):
assert token in self._dict, "<STR_LIT>"<EOL>assert timeout == -<NUM_LIT:1> or timeout > <NUM_LIT:0><EOL>if timeout < <NUM_LIT:0> or timeout > LockStorageDict.LOCK_TIME_OUT_MAX:<EOL><INDENT>timeout = LockStorageDict.LOCK_TIME_OUT_MAX<EOL><DEDENT>self._lock.acquire_write()<EOL>try:<EOL><INDENT>lock = self._dict[token]<EOL>lock["<STR_LIT>"] = timeout<EOL>lock["<STR_LIT>"] = time.time() + timeout<EOL>self._dict[token] = lock<EOL>self._flush()<EOL><DEDENT>finally:<EOL><INDENT>self._lock.release()<EOL><DEDENT>return lock<EOL>
Modify an existing lock's timeout.

        token:
            Valid lock token.
        timeout:
            Suggested lifetime in seconds (-1 for infinite).
            The real expiration time may be shorter than requested!
        Returns:
            Lock dictionary.
            Raises ValueError, if token is invalid.