<commit_before>from functools import update_wrapper
import operator

from flatland.exc import AdaptationError
from flatland.util import Unspecified, threading
from .containers import Array, Mapping
from .scalars import Date, Integer, Scalar, String


class _MetaCompound(type):
    """Adds a class-level initialization hook """

    _lock = threading.Lock()

    def __new__(self, name, bases, members):
        members['_compound_prepared'] = False
        if '__compound_init__' in members:
            members['__compound_init__'] = \
              _wrap_compound_init(members['__compound_init__'])
        return type.__new__(self, name, bases, members)

    def __call__(cls, value=Unspecified, **kw):
        """Run __compound_init__ on first instance construction."""

        # Find **kw that would override existing class properties and
        # remove them from kw.
        overrides = {}
        for key in kw.keys():
            if hasattr(cls, key):
                overrides[key] = kw.pop(key)

        if overrides:
            # If there are overrides, construct a subtype on the fly
            # so that __compound_init__ has a chance to run again with<commit_msg>Switch the __compound_init__ guard to an RLock<commit_after>from functools import update_wrapper
import operator

from flatland.exc import AdaptationError
from flatland.util import Unspecified, threading
from .containers import Array, Mapping
from .scalars import Date, Integer, Scalar, String


class _MetaCompound(type):
    """Adds a class-level initialization hook """

    _lock = threading.RLock()

    def __new__(self, name, bases, members):
        members['_compound_prepared'] = False
        if '__compound_init__' in members:
            members['__compound_init__'] = \
              _wrap_compound_init(members['__compound_init__'])
        return type.__new__(self, name, bases, members)

    def __call__(cls, value=Unspecified, **kw):
        """Run __compound_init__ on first instance construction."""

        # Find **kw that would override existing class properties and
        # remove them from kw.
        overrides = {}
        for key in kw.keys():
            if hasattr(cls, key):
                overrides[key] = kw.pop(key)

        if overrides:
            # If there are overrides, construct a subtype on the fly
            # so that __compound_init__ has a chance to run again with
{'fraction_non_alphanumeric': 0.0825, 'fraction_numerical': 0.0, 'mean_word_length': 2.878836833602585, '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': '1178340', 'n_tokens_mistral': 668, 'n_tokens_neox': 649, 'n_words': 223}