<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _sync_hooks(self, repos, asynchronous=True):
 """Check if a hooks sync task needs to be started."""

        if not asynchronous:
            for repo_id in repos:
                try:
                    with db.session.begin_nested():
                        self.sync_repo_hook(repo_id)
                    db.session.commit()
                except RepositoryAccessError as e:
                    current_app.logger.warning(e.message, exc_info=True)
                except NoResultFound:
                    pass  # Repository not in DB yet
        else:
            # FIXME: We have to commit, in order to have all necessary data?
            db.session.commit()
            sync_hooks.delay(self.user_id, repos)