<commit_before>
# A decorator that will try to run the function.
# and catch a possible connection failure.
# It will then try to reconnect, and retry the
# original call.
def reconnecting(object func):

    def wrapper(*args, **kwargs):
        try:
            return func(*args, **kwargs)

        except RuntimeError, e:
                
            LOGGER.exception("Error running %r", func)

            if str(e) in EX_CONNECTION:
                # print "reconnecting!"
                LOGGER.debug("Connection lost. Retrying call")
                reconnect()
                try:
                    return func(*args, **kwargs)
                except Exception, e:
                    LOGGER.exception("Error re-running %r after reconnect", func)
                    raise
            else:
                raise e

    wrapper.__doc__ = func.__doc__
    return wrapper


# class __wrapper(object):

#     def __init__(self, func):
#         self.func = func
#         self.__doc__ = func.__doc__

#     def __repr__(self):
#         return self.func.__repr__()

#     def __call__(self, *args, **kwargs):
#         try:
#             return self.func(*args, **kwargs)

#         except RuntimeError, e:
            
#             if str(e) in EX_CONNECTION:
#                 LOGGER.debug("Connection lost. Retrying call")
#                 reconnect()
#                 return self.func(*args, **kwargs)
            
#             else:
#                 raise

# def reconnecting(object func):
#     return __wrapper(func)<commit_msg>updating the reconnecting client decorator to try and retain more wrapped metadata<commit_after>
import functools 

# A decorator that will try to run the function.
# and catch a possible connection failure.
# It will then try to reconnect, and retry the
# original call.
def reconnecting(object func):

    @functools.wraps(func, ('__name__', '__doc__'), ('__dict__',))
    def wrapper(*args, **kwargs):
        try:
            return func(*args, **kwargs)

        except RuntimeError, e:
                
            LOGGER.exception("Error running %r", func)

            if str(e) in EX_CONNECTION:
                # print "reconnecting!"
                LOGGER.debug("Connection lost. Retrying call")
                reconnect()
                try:
                    return func(*args, **kwargs)
                except Exception, e:
                    LOGGER.exception("Error re-running %r after reconnect", func)
                    raise
            else:
                raise e

    cdef str attr
    for attr in ('__qualname__', '__module__', '__repr__'):
        try:
            setattr(wrapper, attr, getattr(func, attr))
        except AttributeError:
            pass

    return wrapper

{'fraction_non_alphanumeric': 0.09430540442509974, 'fraction_numerical': 0.0, 'mean_word_length': 1.6724806201550388, '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': '2939177', 'n_tokens_mistral': 739, 'n_tokens_neox': 719, 'n_words': 226}