def _next_XMIT_1(self, intent):
        if hasattr(self, '_openSockets'):
            if intent.targetAddr in self._openSockets:
                intent.socket = self._openSockets[intent.targetAddr].socket
                # This intent takes the open socket; there should be only
                # one intent per target but this "take" prevents an
                # erroneous second target intent from causing corruption.
                # The _finishIntent operation will return the socket to
                # the _openSockets list.  It's possible that both sides
                # will simultaneously attempt to transmit, but this should
                # be rare, and the effect will be that neither will get
                # the expected ACK and will close the socket to be
                # re-opened on the next retry period, which is a
                # reasonable approach.
                del self._openSockets[intent.targetAddr]
                intent.stage = self._XMITStepSendData
                intent.amtSent = 0
                return self._nextTransmitStep(intent)
            # If there is an active or pending Intent for this target,
            # just queue this one (by returning True)
            if any(T for T in self._transmitIntents.values()
                if T.targetAddr == intent.targetAddr and hasattr(T, 'socket')):
                intent.awaitingTXSlot()
                return True
            # Fall through to get a new Socket for this intent
        if isinstance(intent.targetAddr.addressDetails, TXOnlyAdminTCPv4ActorAddress) and \
           intent.targetAddr != self._adminAddr:
            # Cannot initiate outbound connection to this remote Admin; wait for
            # incoming connection instead.
            intent.backoffPause(True)  # KWQ... not really
            intent.stage = self._XMITStepRetry
            return self._nextTransmitStep(intent)
        intent.socket = socket.socket(*intent.targetAddr.addressDetails.socketArgs)
        intent.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        intent.socket.setblocking(0)
        # Disable Nagle to transmit headers and acks asap; our sends are usually small
        intent.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)

        #intent.socket.settimeout(timePeriodSeconds(intent.delay()))
        try:
            intent.socket.connect(*intent.targetAddr.addressDetails.connectArgs)
        except socket.error as err:
            # EINPROGRESS means non-blocking socket connect is in progress...
            if not err_inprogress(err.errno):
                thesplog('Socket connect failure %s to %s on %s (returning %s)',
                         err, intent.targetAddr, intent.socket,
                         intent.completionCallback,
                         level=logging.WARNING)
                return self._finishIntent(intent,
                                          SendStatus.DeadTarget \
                                          if err_conn_refused(err) \
                                          else SendStatus.Failed)
            intent.backoffPause(True)
        except Exception as ex:
            thesplog('Unexpected TCP socket connect exception: %s', ex,
                     level=logging.ERROR)
            return self._finishIntent(intent, SendStatus.BadPacket)
        intent.stage = self._XMITStepSendData # When connect completes
        intent.amtSent = 0
        return True
dataset/ETHPy150Open godaddy/Thespian/thespian/system/transport/TCPTransport.py/TCPTransport._next_XMIT_1/original