def threadsafe_function(fn):
    """decorator making sure that the decorated function is thread safe"""
    lock = threading.Lock()
    def new(*args, **kwargs):
        lock.acquire()
        try:
            r = fn(*args, **kwargs)
        except Exception as e:
            log.debug('threadsafe exception: %s' % e)
            raise NoMPDConnection
        finally:
            lock.release()
        return r
    return new
dataset/ETHPy150Open ralfonso/theory/theory/model/mpdpool.py/threadsafe_function/original