<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""Tests for the QueryCache functionality of johnny."""

from __future__ import print_function
from threading import Thread

from django.conf import settings
from django.core.paginator import Paginator
from django.db import connection, connections, transaction
from django.db.models import Q, Count, Sum
from johnny import middleware, settings as johnny_settings, cache
from johnny.cache import get_tables_for_query, invalidate
from johnny.compat import is_managed, managed, Queue
from johnny.signals import qc_hit, qc_miss, qc_skip
from . import base
from .testapp.models import (
    Genre, Book, Publisher, Person, PersonType, Issue24Model as i24m)


# put tests in here to be included in the testing suite
__all__ = ['MultiDbTest', 'SingleModelTest', 'MultiModelTest', 'TransactionSupportTest', 'BlackListTest', 'TransactionManagerTestCase']


def is_multithreading_safe(db_using=None):
    # SQLite and the file-based cache are not thread-safe.
    if db_using is None:
        return all(is_multithreading_safe(db_using=db_name)
                   for db_name in settings.DATABASES)
    db_engine = settings.DATABASES.get(db_using, {}).get('ENGINE', 'sqlite3')
    return not db_engine.endswith('sqlite3')

<commit_msg>Updates comment.<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""Tests for the QueryCache functionality of johnny."""

from __future__ import print_function
from threading import Thread

from django.conf import settings
from django.core.paginator import Paginator
from django.db import connection, connections, transaction
from django.db.models import Q, Count, Sum
from johnny import middleware, settings as johnny_settings, cache
from johnny.cache import get_tables_for_query, invalidate
from johnny.compat import is_managed, managed, Queue
from johnny.signals import qc_hit, qc_miss, qc_skip
from . import base
from .testapp.models import (
    Genre, Book, Publisher, Person, PersonType, Issue24Model as i24m)


# put tests in here to be included in the testing suite
__all__ = ['MultiDbTest', 'SingleModelTest', 'MultiModelTest', 'TransactionSupportTest', 'BlackListTest', 'TransactionManagerTestCase']


def is_multithreading_safe(db_using=None):
    # SQLite is not thread-safe.
    if db_using is None:
        return all(is_multithreading_safe(db_using=db_name)
                   for db_name in settings.DATABASES)
    db_engine = settings.DATABASES.get(db_using, {}).get('ENGINE', 'sqlite3')
    return not db_engine.endswith('sqlite3')


{'fraction_non_alphanumeric': 0.08702469619756958, 'fraction_numerical': 0.005488043904351235, 'mean_word_length': 4.934883720930233, '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': '6573400', 'n_tokens_mistral': 789, 'n_tokens_neox': 765, 'n_words': 243}