def non_blocking(func):
    """Decorator to run a function in a different thread.
    It can be used to execute a command in a non-blocking way
    like this::

        @non_blocking
        def add_one(n):
            print 'starting'
            import time
            time.sleep(2)
            print 'ending'
            return n+1

        thread = add_one(5) # Starts the function
        result = thread.join() # Waits for it to complete
        print result
    """
    from functools import wraps
    @wraps(func)
    def non_blocking_version(*args, **kwargs):
        t = ReturnThread(target=func, args=args, kwargs=kwargs)
        t.start()
        return t
    return non_blocking_version
def non_blocking ( func ) : from functools import wraps @ wraps ( func ) def non_blocking_version ( * args , ** kwargs ) : t = ReturnThread ( target = func , args = args , kwargs = kwargs ) t . start ( ) return t return non_blocking_version
Decorator to run a function in a different thread.
    It can be used to execute a command in a non-blocking way
    like this::

        @non_blocking
        def add_one(n):
            print 'starting'
            import time
            time.sleep(2)
            print 'ending'
            return n+1

        thread = add_one(5) # Starts the function
        result = thread.join() # Waits for it to complete
        print result