def close(self):
        if self.is_open:
            if self._socket:
                try:
                    self._socket.shutdown(socket.SHUT_RDWR)
                    self._socket.close()
                except:
                    # ignore errors.
                    pass
                self._socket = None
            self.is_open = False
            # in case of quick reconnects, give the server some time
            time.sleep(0.3)
Close port
dataset/ETHPy150Open pyserial/pyserial/serial/urlhandler/protocol_socket.py/Serial.close