def TProxy(obj, lock = RLock()):
    """A factory function wrapping an object in a thread-safe wrapper."""
    if callable(obj):
        return TCallableProxy(obj, lock)
    else:
        return TObjectProxy(obj, lock)
A factory function wrapping an object in a thread-safe wrapper.
recipes/Python/159143_A_ThreadedProxy_wrapper/recipe-159143.py