<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 async def _handle(self, reader, writer):
 """ Handle a single TCP connection Parses requests, finds appropriate handlers and returns responses """

        peer = writer.get_extra_info('peername')
        self._logger.debug('New connection from {}'.format(peer))
        try:
            # Loop handling requests
            while True:
                # Read the request
                req = Request()
                await req._read(reader)

                # Find and execute handler
                res = None
                for path_regex, handler in self._handlers.get(req.method, []):
                    match = path_regex.fullmatch(req.path)
                    if match:
                        req.match = match
                        try:
                            if inspect.iscoroutinefunction(handler):
                                res = await handler(self.env, req)
                            else:
                                res = handler(self.env, req)
                            if not isinstance(res, Response):
                                res = Response(data=res)
                        except:
                            # Error - log it and return 500
                            self._logger.error(traceback.format_exc())
                            res = Response(code=500, reason='Internal Server Error')
                        break

                # No handler - send 404
                if res == None:
                    res = Response(code=404, reason='Not Found')

                # Respond
                await res._write(writer)
                self._logger.info('{}: {} -> {}'.format(peer, req.path,  res.code))
        except EOFError:
            self._logger.debug('Connection closed from {}'.format(peer))
        except Exception as e:
            self._logger.error('Connection error ({}) from {}'.format(e, peer))
            writer.close()