<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def transaction():
 """ Swaps out the current client with a pipeline instance, so that each Redis method call inside the context will be pipelined. Once the context is exited, we execute the pipeline. """

    client = default_client()
    _thread.client = client.pipeline()
    try:
        yield
        _thread.client.execute()
    finally:
        _thread.client = client