<commit_before>import logging

from changes.vcs.base import CommandError, ConcurrentUpdateError
from changes.models import Repository, RepositoryStatus


logger = logging.getLogger('update_local_repo')


def update_local_repos():
    """
    Updates repositories locally.
    """
    repo_list = list(Repository.query.filter(
        Repository.status != RepositoryStatus.inactive,
    ))

    for repo in repo_list:
        vcs = repo.get_vcs()
        if vcs is None:
            logger.warning('Repository %s has no VCS backend set', repo.id)<commit_msg>Avoid long running transactions in update_local_repos.<commit_after>import logging

from changes.config import db
from changes.models import Repository, RepositoryStatus
from changes.vcs.base import CommandError, ConcurrentUpdateError


logger = logging.getLogger('update_local_repo')


def update_local_repos():
    """
    Updates repositories locally.
    """
    repo_list = list(Repository.query.filter(
        Repository.status != RepositoryStatus.inactive,
    ))

    for repo in repo_list:
        vcs = repo.get_vcs()
        # Close the read transaction to avoid a long running transaction
        db.session.commit()

        if vcs is None:
            logger.warning('Repository %s has no VCS backend set', repo.id)
{'fraction_non_alphanumeric': 0.08313908313908314, 'fraction_numerical': 0.0, 'mean_word_length': 3.3959044368600684, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1864081', 'n_tokens_mistral': 365, 'n_tokens_neox': 347, 'n_words': 101}