def try_connect(self): """Creates a socket, connects it to the nailgun and returns the connected socket. :returns: a connected `socket.socket`. :raises: `NailgunClient.NailgunConnectionError` on failure to connect. """ sock = RecvBufferedSocket(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) try: sock.connect((self._host, self._port)) except (socket.error, socket.gaierror) as e: logger.debug('Encountered socket exception {!r} when attempting connect to nailgun'.format(e)) sock.close() raise self.NailgunConnectionError( 'Problem connecting to nailgun server at {}:{}: {!r}'.format(self._host, self._port, e)) else: return sock
def try_connect(self): """Creates a socket, connects it to the nailgun and returns the connected socket. :returns: a connected `socket.socket`. :raises: `NailgunClient.NailgunConnectionError` on failure to connect. """ sock = RecvBufferedSocket(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) try: sock.connect(self._address) except (socket.error, socket.gaierror) as e: logger.debug('Encountered socket exception {!r} when attempting connect to nailgun'.format(e)) sock.close() raise self.NailgunConnectionError( address=self._address_string, pid=self.pid, wrapped_exc=e, traceback=sys.exc_info()[2] ) else: return sock
def try_connect(self): """Creates a socket, connects it to the nailgun and returns the connected socket. :returns: a connected `socket.socket`. :raises: `NailgunClient.NailgunConnectionError` on failure to connect. """ sock = RecvBufferedSocket(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) try: sock.connect(self._address) except (socket.error, socket.gaierror) as e: logger.debug('Encountered socket exception {!r} when attempting connect to nailgun'.format(e)) sock.close() raise self.NailgunConnectionError( address=self._address_string, pid=self._maybe_last_pid(), pgrp=self._maybe_last_pgrp(), wrapped_exc=e, ) else: return sock
def try_connect(self): """Creates a socket, connects it to the nailgun and returns the connected socket. :returns: a connected `socket.socket`. :raises: `NailgunClient.NailgunConnectionError` on failure to connect. """ sock = RecvBufferedSocket( sock=socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM)) try: sock.connect(self._address) except (socket.error, socket.gaierror) as e: logger.debug( "Encountered socket exception {!r} when attempting connect to nailgun" .format(e)) sock.close() raise self.NailgunConnectionError( address=self._address_string, pid=self._maybe_last_pid(), pgrp=self._maybe_last_pgrp(), wrapped_exc=e, ) else: return sock