def METHOD_NAME(self, folder, criteria, charset):
    try:
        self.crispin_client.select_folder(folder.name, uidvalidity_cb)
    except FolderMissingError:
        self.log.warn("Won't search missing IMAP folder", exc_info=True)
        return []
    except UidInvalid:
        self.log.error(
            ("Got Uidvalidity error when searching. Skipping."), exc_info=True
        )
        return []
    try:
        uids = self.crispin_client.conn.search(criteria, charset=charset)
    except IMAP4.error:
        self.log.warn("Search error", exc_info=True)
        raise SearchBackendException(
            ("Unknown IMAP error when performing search."), 503
        )
    self.log.debug(
        "Search found messages for folder", folder_name=folder.id, uids=len(uids)
    )
    return uids