def handle(self):
        with self._lock:
            self.worker.nb_connections +=1
            self.worker.refresh_name()

        try:
            while not self.connected:
                data = self.sock.recv(1024)
                if not data:
                    break
                self.buf.append(data)
                if self.remote is None:
                    try:
                        self.do_proxy()
                    except StopIteration:
                        break
        except ConnectionError, e:
            log.error("Error while connecting: [%s]" % str(e))
            self.handle_error(e)
        except InactivityTimeout, e:
            log.warn("inactivity timeout")
            self.handle_error(e)
        except socket.error, e:
            log.error("socket.error: [%s]" % str(e))
            self.handle_error(e)
        except greenlet.GreenletExit:
            pass
        except __HOLE__:
            pass
        except Exception, e:
            log.error("unknown error %s" % str(e))
        finally:
            if self.remote is not None:
                log.debug("Close connection to %s:%s" % self.remote)

            with self._lock:
                self.worker.nb_connections -=1
                self.worker.refresh_name()
            _closesocket(self.sock)
dataset/ETHPy150Open benoitc/tproxy/tproxy/client.py/ClientConnection.handle