def disconnect(self): ''' Closes connection to a server. ''' try: if self.socket: self._mutex.acquire() try: self.close() finally: self._mutex.release() except socket.error, err: self.messages.put(Error(connection.processSocketError(err)))
def handle_error(self): ''' Method for handling uncaptured errors. ''' t, err, tbinfo = asyncore.compact_traceback()[1:] self.onError(Exception("%s:%s\n%s" % (t, err, tbinfo[1:-1].replace("] [", "\n")))) if isinstance(err, socket.error): if connection.closingSocketError(err): pass elif connection.minorSocketError(err): return else: self.onError(connection.ConnectionError( connection.processSocketError(err))) self.disconnect()
def handle_error(self): ''' Method for handling uncaptured errors. ''' err = asyncore.compact_traceback()[2] error = Error(err) if isinstance(err, socket.error): if connection.closingSocketError(err): self.handle_close() return elif connection.minorSocketError(err): self.disconnect() return elif err[0] in (10060, 110): #WSATIMEDOUT error keeps occurring if socket isn't closed self.disconnect() elif err[0] in self.errorStrs: error = ConnectionRefusedError(self.errorStrs[err[0]]) self.disconnect() else: error = ConnectionRefusedError( connection.processSocketError(err)) self.disconnect() self.messages.put(error)