<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def update_bookmark(self, old, new, *, max_retries=3):
 """ Update a bookmark and check it was successful. The bookmark matches an existing bookmark `old` according to bookmark equalitiy and replaces it by `new`. The bookmark `new` is added if no bookmark matching `old` exists. :param old: the bookmark to replace :type bookmark_to_remove: a :class:`~bookmark_xso.Bookmark` subclass. :param new: the replacement bookmark :type bookmark_to_remove: a :class:`~bookmark_xso.Bookmark` subclass. :param max_retries: the number of retries of removing the bookmark fails. :type max_retries: :class:`int` :raises RuntimeError: if the bookmark is not in the bookmark list after `max_retries` retries. After replacing the bookmark it is checked, whether the bookmark `new` is in the online storage, if it is not it is tried again at most `max_retries` times to replace the bookmark. A :class:`RuntimeError` is raised if the bookmark could not be replaced successfully after `max_retries`. .. note:: Do not modify a bookmark retrieved from the signals or from :meth:`get_bookmarks` to obtain the bookmark `new`, this will lead to data corruption as they are passed by reference. Instead use :func:`copy.copy` and modify the copy. """

        def replace_bookmark(bookmarks, old, new):
            modified_bookmarks = list(bookmarks)
            try:
                i = bookmarks.index(old)
                modified_bookmarks[i] = new
            except ValueError:
                modified_bookmarks.append(new)
            return modified_bookmarks

        with (yield from self._lock):
            bookmarks = yield from self._get_bookmarks()

            try:
                yield from self._set_bookmarks(
                    replace_bookmark(bookmarks, old, new)
                )

                retries = 0
                bookmarks = yield from self._get_bookmarks()
                while retries < max_retries:
                    if new in bookmarks:
                        break
                    yield from self._set_bookmarks(
                        replace_bookmark(bookmarks, old, new)
                    )
                    bookmarks = yield from self._get_bookmarks()
                    retries += 1

                if new not in bookmarks:
                    raise RuntimeError("Cold not update bookmark")
            finally:
                self._diff_emit_update(bookmarks)