我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用socket.EBADF。
def close(self): if hasattr(self.socket, '_sock'): try: self.socket._sock.close() except socket.error: info = sys.exc_info() if info[1].args[0] != socket.EBADF: raise info[1] else: pass self.socket.close() # Monolithic build...end of module: rocket/connection.py # Monolithic build...start of module: rocket/filelike.py # Import System Modules
def send_response(self, status): stat_msg = status.split(' ', 1)[1] msg = RESPONSE % (status, len(stat_msg), 'text/plain', stat_msg) try: self.conn.sendall(b(msg)) except socket.error: self.closeConnection = True self.err_log.error('Tried to send "%s" to client but received socket' ' error' % status) #def kill(self): # if self.isAlive() and hasattr(self, 'conn'): # try: # self.conn.shutdown(socket.SHUT_RDWR) # except socket.error: # info = sys.exc_info() # if info[1].args[0] != socket.EBADF: # self.err_log.debug('Error on shutdown: '+str(info))
def run(self): while not self.zc.done: with self.condition: rs = self.readers.keys() if len(rs) == 0: # No sockets to manage, but we wait for the timeout # or addition of a socket self.condition.wait(self.timeout) if len(rs) != 0: try: rr, wr, er = select.select(rs, [], [], self.timeout) if not self.zc.done: for socket_ in rr: reader = self.readers.get(socket_) if reader: reader.handle_read(socket_) except (select.error, socket.error) as e: # If the socket was closed by another thread, during # shutdown, ignore it and exit if e.args[0] != socket.EBADF or not self.zc.done: raise