<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _connection(self):
 """ If we have a pipeline, shared in thread, or in the good thread, return it else use the direct connection """

        if self._pipelined_connection is not None:
            if self._pipelined_connection.share_in_threads or \
                    threading.current_thread().ident == self._pipelined_connection.current_thread_id:
                return self._pipelined_connection


        return self._direct_connection