<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_mailbox(self, mailbox_name='inbox'):
 """Update the mailbox associated with the given mailbox name. """

        with txn() as session:
            last_updated_name = '{0}_last_updated'.format(mailbox_name)
            okcupyd_user = session.query(model.OKCupydUser).join(model.User).filter(
                model.User.okc_id == self._user.profile.id
            ).with_for_update().one()
            log.info(simplejson.dumps({
                '{0}_last_updated'.format(mailbox_name): helpers.datetime_to_string(
                    getattr(okcupyd_user, last_updated_name)
                )
            }))

            res = self._sync_mailbox_until(
                getattr(self._user, mailbox_name)(),
                getattr(okcupyd_user, last_updated_name)
            )
            if not res:
                return None, None

            last_updated, threads, new_messages = res
            if last_updated:
                setattr(okcupyd_user, last_updated_name, last_updated)
            return threads, new_messages