{
    "file_diffs": [
        {
            "old_file_content": "",
            "new_file_content": "Fix GunicornWebWorker max_requests_jitter not work\n",
            "header": {
                "file": {
                    "path": "CHANGES/7518.bugfix"
                },
                "misc_line": "new file mode 100644"
            },
            "index_line": {
                "old_commit_hash": "00000000",
                "new_commit_hash": "bc8083ba",
                "mode": ""
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "/dev/null"
            },
            "plus_file": {
                "path": "b/CHANGES/7518.bugfix"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 0,
                            "length": 0
                        },
                        "new_range": {
                            "start": 1,
                            "length": null
                        },
                        "section": ""
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "Fix GunicornWebWorker max_requests_jitter not work",
                                "type": "added"
                            }
                        ]
                    },
                    "modified_entities": [],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        },
        {
            "old_file_content": "\"\"\"Async gunicorn worker for aiohttp.web\"\"\"\n\nimport asyncio\nimport os\nimport re\nimport signal\nimport sys\nfrom types import FrameType\nfrom typing import Any, Awaitable, Callable, Optional, Union  # noqa\n\nfrom gunicorn.config import AccessLogFormat as GunicornAccessLogFormat\nfrom gunicorn.workers import base\n\nfrom aiohttp import web\n\nfrom .helpers import set_result\nfrom .web_app import Application\nfrom .web_log import AccessLogger\n\ntry:\n    import ssl\n\n    SSLContext = ssl.SSLContext\nexcept ImportError:  # pragma: no cover\n    ssl = None  # type: ignore[assignment]\n    SSLContext = object  # type: ignore[misc,assignment]\n\n\n__all__ = (\"GunicornWebWorker\", \"GunicornUVLoopWebWorker\")\n\n\nclass GunicornWebWorker(base.Worker):  # type: ignore[misc,no-any-unimported]\n\n    DEFAULT_AIOHTTP_LOG_FORMAT = AccessLogger.LOG_FORMAT\n    DEFAULT_GUNICORN_LOG_FORMAT = GunicornAccessLogFormat.default\n\n    def __init__(self, *args: Any, **kw: Any) -> None:  # pragma: no cover\n        super().__init__(*args, **kw)\n\n        self._task: Optional[asyncio.Task[None]] = None\n        self.exit_code = 0\n        self._notify_waiter: Optional[asyncio.Future[bool]] = None\n\n    def init_process(self) -> None:\n        # create new event_loop after fork\n        asyncio.get_event_loop().close()\n\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(self.loop)\n\n        super().init_process()\n\n    def run(self) -> None:\n        self._task = self.loop.create_task(self._run())\n\n        try:  # ignore all finalization problems\n            self.loop.run_until_complete(self._task)\n        except Exception:\n            self.log.exception(\"Exception in gunicorn worker\")\n        self.loop.run_until_complete(self.loop.shutdown_asyncgens())\n        self.loop.close()\n\n        sys.exit(self.exit_code)\n\n    async def _run(self) -> None:\n        runner = None\n        if isinstance(self.wsgi, Application):\n            app = self.wsgi\n        elif asyncio.iscoroutinefunction(self.wsgi):\n            wsgi = await self.wsgi()\n            if isinstance(wsgi, web.AppRunner):\n                runner = wsgi\n                app = runner.app\n            else:\n                app = wsgi\n        else:\n            raise RuntimeError(\n                \"wsgi app should be either Application or \"\n                \"async function returning Application, got {}\".format(self.wsgi)\n            )\n\n        if runner is None:\n            access_log = self.log.access_log if self.cfg.accesslog else None\n            runner = web.AppRunner(\n                app,\n                logger=self.log,\n                keepalive_timeout=self.cfg.keepalive,\n                access_log=access_log,\n                access_log_format=self._get_valid_log_format(\n                    self.cfg.access_log_format\n                ),\n            )\n        await runner.setup()\n\n        ctx = self._create_ssl_context(self.cfg) if self.cfg.is_ssl else None\n\n        runner = runner\n        assert runner is not None\n        server = runner.server\n        assert server is not None\n        for sock in self.sockets:\n            site = web.SockSite(\n                runner,\n                sock,\n                ssl_context=ctx,\n                shutdown_timeout=self.cfg.graceful_timeout / 100 * 95,\n            )\n            await site.start()\n\n        # If our parent changed then we shut down.\n        pid = os.getpid()\n        try:\n            while self.alive:  # type: ignore[has-type]\n                self.notify()\n\n                cnt = server.requests_count\n                if self.cfg.max_requests and cnt > self.cfg.max_requests:\n                    self.alive = False\n                    self.log.info(\"Max requests, shutting down: %s\", self)\n\n                elif pid == os.getpid() and self.ppid != os.getppid():\n                    self.alive = False\n                    self.log.info(\"Parent changed, shutting down: %s\", self)\n                else:\n                    await self._wait_next_notify()\n        except BaseException:\n            pass\n\n        await runner.cleanup()\n\n    def _wait_next_notify(self) -> \"asyncio.Future[bool]\":\n        self._notify_waiter_done()\n\n        loop = self.loop\n        assert loop is not None\n        self._notify_waiter = waiter = loop.create_future()\n        self.loop.call_later(1.0, self._notify_waiter_done, waiter)\n\n        return waiter\n\n    def _notify_waiter_done(\n        self, waiter: Optional[\"asyncio.Future[bool]\"] = None\n    ) -> None:\n        if waiter is None:\n            waiter = self._notify_waiter\n        if waiter is not None:\n            set_result(waiter, True)\n\n        if waiter is self._notify_waiter:\n            self._notify_waiter = None\n\n    def init_signals(self) -> None:\n        # Set up signals through the event loop API.\n\n        self.loop.add_signal_handler(\n            signal.SIGQUIT, self.handle_quit, signal.SIGQUIT, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGTERM, self.handle_exit, signal.SIGTERM, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGINT, self.handle_quit, signal.SIGINT, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGWINCH, self.handle_winch, signal.SIGWINCH, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGUSR1, self.handle_usr1, signal.SIGUSR1, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGABRT, self.handle_abort, signal.SIGABRT, None\n        )\n\n        # Don't let SIGTERM and SIGUSR1 disturb active requests\n        # by interrupting system calls\n        signal.siginterrupt(signal.SIGTERM, False)\n        signal.siginterrupt(signal.SIGUSR1, False)\n        # Reset signals so Gunicorn doesn't swallow subprocess return codes\n        # See: https://github.com/aio-libs/aiohttp/issues/6130\n\n    def handle_quit(self, sig: int, frame: Optional[FrameType]) -> None:\n        self.alive = False\n\n        # worker_int callback\n        self.cfg.worker_int(self)\n\n        # wakeup closing process\n        self._notify_waiter_done()\n\n    def handle_abort(self, sig: int, frame: Optional[FrameType]) -> None:\n        self.alive = False\n        self.exit_code = 1\n        self.cfg.worker_abort(self)\n        sys.exit(1)\n\n    @staticmethod\n    def _create_ssl_context(cfg: Any) -> \"SSLContext\":\n        \"\"\"Creates SSLContext instance for usage in asyncio.create_server.\n\n        See ssl.SSLSocket.__init__ for more details.\n        \"\"\"\n        if ssl is None:  # pragma: no cover\n            raise RuntimeError(\"SSL is not supported.\")\n\n        ctx = ssl.SSLContext(cfg.ssl_version)\n        ctx.load_cert_chain(cfg.certfile, cfg.keyfile)\n        ctx.verify_mode = cfg.cert_reqs\n        if cfg.ca_certs:\n            ctx.load_verify_locations(cfg.ca_certs)\n        if cfg.ciphers:\n            ctx.set_ciphers(cfg.ciphers)\n        return ctx\n\n    def _get_valid_log_format(self, source_format: str) -> str:\n        if source_format == self.DEFAULT_GUNICORN_LOG_FORMAT:\n            return self.DEFAULT_AIOHTTP_LOG_FORMAT\n        elif re.search(r\"%\\([^\\)]+\\)\", source_format):\n            raise ValueError(\n                \"Gunicorn's style options in form of `%(name)s` are not \"\n                \"supported for the log formatting. Please use aiohttp's \"\n                \"format specification to configure access log formatting: \"\n                \"http://docs.aiohttp.org/en/stable/logging.html\"\n                \"#format-specification\"\n            )\n        else:\n            return source_format\n\n\nclass GunicornUVLoopWebWorker(GunicornWebWorker):\n    def init_process(self) -> None:\n        import uvloop\n\n        # Close any existing event loop before setting a\n        # new policy.\n        asyncio.get_event_loop().close()\n\n        # Setup uvloop policy, so that every\n        # asyncio.get_event_loop() will create an instance\n        # of uvloop event loop.\n        asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())\n\n        super().init_process()\n",
            "new_file_content": "\"\"\"Async gunicorn worker for aiohttp.web\"\"\"\n\nimport asyncio\nimport os\nimport re\nimport signal\nimport sys\nfrom types import FrameType\nfrom typing import Any, Awaitable, Callable, Optional, Union  # noqa\n\nfrom gunicorn.config import AccessLogFormat as GunicornAccessLogFormat\nfrom gunicorn.workers import base\n\nfrom aiohttp import web\n\nfrom .helpers import set_result\nfrom .web_app import Application\nfrom .web_log import AccessLogger\n\ntry:\n    import ssl\n\n    SSLContext = ssl.SSLContext\nexcept ImportError:  # pragma: no cover\n    ssl = None  # type: ignore[assignment]\n    SSLContext = object  # type: ignore[misc,assignment]\n\n\n__all__ = (\"GunicornWebWorker\", \"GunicornUVLoopWebWorker\")\n\n\nclass GunicornWebWorker(base.Worker):  # type: ignore[misc,no-any-unimported]\n\n    DEFAULT_AIOHTTP_LOG_FORMAT = AccessLogger.LOG_FORMAT\n    DEFAULT_GUNICORN_LOG_FORMAT = GunicornAccessLogFormat.default\n\n    def __init__(self, *args: Any, **kw: Any) -> None:  # pragma: no cover\n        super().__init__(*args, **kw)\n\n        self._task: Optional[asyncio.Task[None]] = None\n        self.exit_code = 0\n        self._notify_waiter: Optional[asyncio.Future[bool]] = None\n\n    def init_process(self) -> None:\n        # create new event_loop after fork\n        asyncio.get_event_loop().close()\n\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(self.loop)\n\n        super().init_process()\n\n    def run(self) -> None:\n        self._task = self.loop.create_task(self._run())\n\n        try:  # ignore all finalization problems\n            self.loop.run_until_complete(self._task)\n        except Exception:\n            self.log.exception(\"Exception in gunicorn worker\")\n        self.loop.run_until_complete(self.loop.shutdown_asyncgens())\n        self.loop.close()\n\n        sys.exit(self.exit_code)\n\n    async def _run(self) -> None:\n        runner = None\n        if isinstance(self.wsgi, Application):\n            app = self.wsgi\n        elif asyncio.iscoroutinefunction(self.wsgi):\n            wsgi = await self.wsgi()\n            if isinstance(wsgi, web.AppRunner):\n                runner = wsgi\n                app = runner.app\n            else:\n                app = wsgi\n        else:\n            raise RuntimeError(\n                \"wsgi app should be either Application or \"\n                \"async function returning Application, got {}\".format(self.wsgi)\n            )\n\n        if runner is None:\n            access_log = self.log.access_log if self.cfg.accesslog else None\n            runner = web.AppRunner(\n                app,\n                logger=self.log,\n                keepalive_timeout=self.cfg.keepalive,\n                access_log=access_log,\n                access_log_format=self._get_valid_log_format(\n                    self.cfg.access_log_format\n                ),\n            )\n        await runner.setup()\n\n        ctx = self._create_ssl_context(self.cfg) if self.cfg.is_ssl else None\n\n        runner = runner\n        assert runner is not None\n        server = runner.server\n        assert server is not None\n        for sock in self.sockets:\n            site = web.SockSite(\n                runner,\n                sock,\n                ssl_context=ctx,\n                shutdown_timeout=self.cfg.graceful_timeout / 100 * 95,\n            )\n            await site.start()\n\n        # If our parent changed then we shut down.\n        pid = os.getpid()\n        try:\n            while self.alive:  # type: ignore[has-type]\n                self.notify()\n\n                cnt = server.requests_count\n                if self.max_requests and cnt > self.max_requests:\n                    self.alive = False\n                    self.log.info(\"Max requests, shutting down: %s\", self)\n\n                elif pid == os.getpid() and self.ppid != os.getppid():\n                    self.alive = False\n                    self.log.info(\"Parent changed, shutting down: %s\", self)\n                else:\n                    await self._wait_next_notify()\n        except BaseException:\n            pass\n\n        await runner.cleanup()\n\n    def _wait_next_notify(self) -> \"asyncio.Future[bool]\":\n        self._notify_waiter_done()\n\n        loop = self.loop\n        assert loop is not None\n        self._notify_waiter = waiter = loop.create_future()\n        self.loop.call_later(1.0, self._notify_waiter_done, waiter)\n\n        return waiter\n\n    def _notify_waiter_done(\n        self, waiter: Optional[\"asyncio.Future[bool]\"] = None\n    ) -> None:\n        if waiter is None:\n            waiter = self._notify_waiter\n        if waiter is not None:\n            set_result(waiter, True)\n\n        if waiter is self._notify_waiter:\n            self._notify_waiter = None\n\n    def init_signals(self) -> None:\n        # Set up signals through the event loop API.\n\n        self.loop.add_signal_handler(\n            signal.SIGQUIT, self.handle_quit, signal.SIGQUIT, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGTERM, self.handle_exit, signal.SIGTERM, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGINT, self.handle_quit, signal.SIGINT, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGWINCH, self.handle_winch, signal.SIGWINCH, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGUSR1, self.handle_usr1, signal.SIGUSR1, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGABRT, self.handle_abort, signal.SIGABRT, None\n        )\n\n        # Don't let SIGTERM and SIGUSR1 disturb active requests\n        # by interrupting system calls\n        signal.siginterrupt(signal.SIGTERM, False)\n        signal.siginterrupt(signal.SIGUSR1, False)\n        # Reset signals so Gunicorn doesn't swallow subprocess return codes\n        # See: https://github.com/aio-libs/aiohttp/issues/6130\n\n    def handle_quit(self, sig: int, frame: Optional[FrameType]) -> None:\n        self.alive = False\n\n        # worker_int callback\n        self.cfg.worker_int(self)\n\n        # wakeup closing process\n        self._notify_waiter_done()\n\n    def handle_abort(self, sig: int, frame: Optional[FrameType]) -> None:\n        self.alive = False\n        self.exit_code = 1\n        self.cfg.worker_abort(self)\n        sys.exit(1)\n\n    @staticmethod\n    def _create_ssl_context(cfg: Any) -> \"SSLContext\":\n        \"\"\"Creates SSLContext instance for usage in asyncio.create_server.\n\n        See ssl.SSLSocket.__init__ for more details.\n        \"\"\"\n        if ssl is None:  # pragma: no cover\n            raise RuntimeError(\"SSL is not supported.\")\n\n        ctx = ssl.SSLContext(cfg.ssl_version)\n        ctx.load_cert_chain(cfg.certfile, cfg.keyfile)\n        ctx.verify_mode = cfg.cert_reqs\n        if cfg.ca_certs:\n            ctx.load_verify_locations(cfg.ca_certs)\n        if cfg.ciphers:\n            ctx.set_ciphers(cfg.ciphers)\n        return ctx\n\n    def _get_valid_log_format(self, source_format: str) -> str:\n        if source_format == self.DEFAULT_GUNICORN_LOG_FORMAT:\n            return self.DEFAULT_AIOHTTP_LOG_FORMAT\n        elif re.search(r\"%\\([^\\)]+\\)\", source_format):\n            raise ValueError(\n                \"Gunicorn's style options in form of `%(name)s` are not \"\n                \"supported for the log formatting. Please use aiohttp's \"\n                \"format specification to configure access log formatting: \"\n                \"http://docs.aiohttp.org/en/stable/logging.html\"\n                \"#format-specification\"\n            )\n        else:\n            return source_format\n\n\nclass GunicornUVLoopWebWorker(GunicornWebWorker):\n    def init_process(self) -> None:\n        import uvloop\n\n        # Close any existing event loop before setting a\n        # new policy.\n        asyncio.get_event_loop().close()\n\n        # Setup uvloop policy, so that every\n        # asyncio.get_event_loop() will create an instance\n        # of uvloop event loop.\n        asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())\n\n        super().init_process()\n",
            "header": {
                "file": {
                    "path": "aiohttp/worker.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "975046e6",
                "new_commit_hash": "04822f33",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/aiohttp/worker.py"
            },
            "plus_file": {
                "path": "b/aiohttp/worker.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 114,
                            "length": 7
                        },
                        "new_range": {
                            "start": 114,
                            "length": 7
                        },
                        "section": "class GunicornWebWorker(base.Worker):  # type: ignore[misc,no-any-unimported]"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "                self.notify()",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "                cnt = server.requests_count",
                                "type": "context"
                            },
                            {
                                "content": "                if self.cfg.max_requests and cnt > self.cfg.max_requests:",
                                "type": "deleted"
                            },
                            {
                                "content": "                if self.max_requests and cnt > self.max_requests:",
                                "type": "added"
                            },
                            {
                                "content": "                    self.alive = False",
                                "type": "context"
                            },
                            {
                                "content": "                    self.log.info(\"Max requests, shutting down: %s\", self)",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "aiohttp/worker.py",
                            "type": "method",
                            "name": "GunicornWebWorker._run",
                            "content": "class GunicornWebWorker(base.Worker):  # type: ignore[misc,no-any-unimported]\n\n    DEFAULT_AIOHTTP_LOG_FORMAT = AccessLogger.LOG_FORMAT\n    DEFAULT_GUNICORN_LOG_FORMAT = GunicornAccessLogFormat.default\n\n    def __init__(self, *args: Any, **kw: Any) -> None:  # pragma: no cover\n        super().__init__(*args, **kw)\n\n        self._task: Optional[asyncio.Task[None]] = None\n        self.exit_code = 0\n        self._notify_waiter: Optional[asyncio.Future[bool]] = None\n\n    def init_process(self) -> None:\n        # create new event_loop after fork\n        asyncio.get_event_loop().close()\n\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(self.loop)\n\n        super().init_process()\n\n    def run(self) -> None:\n        self._task = self.loop.create_task(self._run())\n\n        try:  # ignore all finalization problems\n            self.loop.run_until_complete(self._task)\n        except Exception:\n            self.log.exception(\"Exception in gunicorn worker\")\n        self.loop.run_until_complete(self.loop.shutdown_asyncgens())\n        self.loop.close()\n\n        sys.exit(self.exit_code)\n\n    async def _run(self) -> None:\n        runner = None\n        if isinstance(self.wsgi, Application):\n            app = self.wsgi\n        elif asyncio.iscoroutinefunction(self.wsgi):\n            wsgi = await self.wsgi()\n            if isinstance(wsgi, web.AppRunner):\n                runner = wsgi\n                app = runner.app\n            else:\n                app = wsgi\n        else:\n            raise RuntimeError(\n                \"wsgi app should be either Application or \"\n                \"async function returning Application, got {}\".format(self.wsgi)\n            )\n\n        if runner is None:\n            access_log = self.log.access_log if self.cfg.accesslog else None\n            runner = web.AppRunner(\n                app,\n                logger=self.log,\n                keepalive_timeout=self.cfg.keepalive,\n                access_log=access_log,\n                access_log_format=self._get_valid_log_format(\n                    self.cfg.access_log_format\n                ),\n            )\n        await runner.setup()\n\n        ctx = self._create_ssl_context(self.cfg) if self.cfg.is_ssl else None\n\n        runner = runner\n        assert runner is not None\n        server = runner.server\n        assert server is not None\n        for sock in self.sockets:\n            site = web.SockSite(\n                runner,\n                sock,\n                ssl_context=ctx,\n                shutdown_timeout=self.cfg.graceful_timeout / 100 * 95,\n            )\n            await site.start()\n\n        # If our parent changed then we shut down.\n        pid = os.getpid()\n        try:\n            while self.alive:  # type: ignore[has-type]\n                self.notify()\n\n                cnt = server.requests_count\n                if self.cfg.max_requests and cnt > self.cfg.max_requests:\n                    self.alive = False\n                    self.log.info(\"Max requests, shutting down: %s\", self)\n\n                elif pid == os.getpid() and self.ppid != os.getppid():\n                    self.alive = False\n                    self.log.info(\"Parent changed, shutting down: %s\", self)\n                else:\n                    await self._wait_next_notify()\n        except BaseException:\n            pass\n\n        await runner.cleanup()\n\n    def _wait_next_notify(self) -> \"asyncio.Future[bool]\":\n        self._notify_waiter_done()\n\n        loop = self.loop\n        assert loop is not None\n        self._notify_waiter = waiter = loop.create_future()\n        self.loop.call_later(1.0, self._notify_waiter_done, waiter)\n\n        return waiter\n\n    def _notify_waiter_done(\n        self, waiter: Optional[\"asyncio.Future[bool]\"] = None\n    ) -> None:\n        if waiter is None:\n            waiter = self._notify_waiter\n        if waiter is not None:\n            set_result(waiter, True)\n\n        if waiter is self._notify_waiter:\n            self._notify_waiter = None\n\n    def init_signals(self) -> None:\n        # Set up signals through the event loop API.\n\n        self.loop.add_signal_handler(\n            signal.SIGQUIT, self.handle_quit, signal.SIGQUIT, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGTERM, self.handle_exit, signal.SIGTERM, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGINT, self.handle_quit, signal.SIGINT, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGWINCH, self.handle_winch, signal.SIGWINCH, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGUSR1, self.handle_usr1, signal.SIGUSR1, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGABRT, self.handle_abort, signal.SIGABRT, None\n        )\n\n        # Don't let SIGTERM and SIGUSR1 disturb active requests\n        # by interrupting system calls\n        signal.siginterrupt(signal.SIGTERM, False)\n        signal.siginterrupt(signal.SIGUSR1, False)\n        # Reset signals so Gunicorn doesn't swallow subprocess return codes\n        # See: https://github.com/aio-libs/aiohttp/issues/6130\n\n    def handle_quit(self, sig: int, frame: Optional[FrameType]) -> None:\n        self.alive = False\n\n        # worker_int callback\n        self.cfg.worker_int(self)\n\n        # wakeup closing process\n        self._notify_waiter_done()\n\n    def handle_abort(self, sig: int, frame: Optional[FrameType]) -> None:\n        self.alive = False\n        self.exit_code = 1\n        self.cfg.worker_abort(self)\n        sys.exit(1)\n\n    @staticmethod\n    def _create_ssl_context(cfg: Any) -> \"SSLContext\":\n        \"\"\"Creates SSLContext instance for usage in asyncio.create_server.\n\n        See ssl.SSLSocket.__init__ for more details.\n        \"\"\"\n        if ssl is None:  # pragma: no cover\n            raise RuntimeError(\"SSL is not supported.\")\n\n        ctx = ssl.SSLContext(cfg.ssl_version)\n        ctx.load_cert_chain(cfg.certfile, cfg.keyfile)\n        ctx.verify_mode = cfg.cert_reqs\n        if cfg.ca_certs:\n            ctx.load_verify_locations(cfg.ca_certs)\n        if cfg.ciphers:\n            ctx.set_ciphers(cfg.ciphers)\n        return ctx\n\n    def _get_valid_log_format(self, source_format: str) -> str:\n        if source_format == self.DEFAULT_GUNICORN_LOG_FORMAT:\n            return self.DEFAULT_AIOHTTP_LOG_FORMAT\n        elif re.search(r\"%\\([^\\)]+\\)\", source_format):\n            raise ValueError(\n                \"Gunicorn's style options in form of `%(name)s` are not \"\n                \"supported for the log formatting. Please use aiohttp's \"\n                \"format specification to configure access log formatting: \"\n                \"http://docs.aiohttp.org/en/stable/logging.html\"\n                \"#format-specification\"\n            )\n        else:\n            return source_format",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 65,
                            "end_lineno": 129,
                            "parent": {
                                "file_name": "aiohttp/worker.py",
                                "type": "class",
                                "name": "GunicornWebWorker",
                                "content": "class GunicornWebWorker(base.Worker):  # type: ignore[misc,no-any-unimported]\n\n    DEFAULT_AIOHTTP_LOG_FORMAT = AccessLogger.LOG_FORMAT\n    DEFAULT_GUNICORN_LOG_FORMAT = GunicornAccessLogFormat.default\n\n    def __init__(self, *args: Any, **kw: Any) -> None:  # pragma: no cover\n        super().__init__(*args, **kw)\n\n        self._task: Optional[asyncio.Task[None]] = None\n        self.exit_code = 0\n        self._notify_waiter: Optional[asyncio.Future[bool]] = None\n\n    def init_process(self) -> None:\n        # create new event_loop after fork\n        asyncio.get_event_loop().close()\n\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(self.loop)\n\n        super().init_process()\n\n    def run(self) -> None:\n        self._task = self.loop.create_task(self._run())\n\n        try:  # ignore all finalization problems\n            self.loop.run_until_complete(self._task)\n        except Exception:\n            self.log.exception(\"Exception in gunicorn worker\")\n        self.loop.run_until_complete(self.loop.shutdown_asyncgens())\n        self.loop.close()\n\n        sys.exit(self.exit_code)\n\n    async def _run(self) -> None:\n        runner = None\n        if isinstance(self.wsgi, Application):\n            app = self.wsgi\n        elif asyncio.iscoroutinefunction(self.wsgi):\n            wsgi = await self.wsgi()\n            if isinstance(wsgi, web.AppRunner):\n                runner = wsgi\n                app = runner.app\n            else:\n                app = wsgi\n        else:\n            raise RuntimeError(\n                \"wsgi app should be either Application or \"\n                \"async function returning Application, got {}\".format(self.wsgi)\n            )\n\n        if runner is None:\n            access_log = self.log.access_log if self.cfg.accesslog else None\n            runner = web.AppRunner(\n                app,\n                logger=self.log,\n                keepalive_timeout=self.cfg.keepalive,\n                access_log=access_log,\n                access_log_format=self._get_valid_log_format(\n                    self.cfg.access_log_format\n                ),\n            )\n        await runner.setup()\n\n        ctx = self._create_ssl_context(self.cfg) if self.cfg.is_ssl else None\n\n        runner = runner\n        assert runner is not None\n        server = runner.server\n        assert server is not None\n        for sock in self.sockets:\n            site = web.SockSite(\n                runner,\n                sock,\n                ssl_context=ctx,\n                shutdown_timeout=self.cfg.graceful_timeout / 100 * 95,\n            )\n            await site.start()\n\n        # If our parent changed then we shut down.\n        pid = os.getpid()\n        try:\n            while self.alive:  # type: ignore[has-type]\n                self.notify()\n\n                cnt = server.requests_count\n                if self.cfg.max_requests and cnt > self.cfg.max_requests:\n                    self.alive = False\n                    self.log.info(\"Max requests, shutting down: %s\", self)\n\n                elif pid == os.getpid() and self.ppid != os.getppid():\n                    self.alive = False\n                    self.log.info(\"Parent changed, shutting down: %s\", self)\n                else:\n                    await self._wait_next_notify()\n        except BaseException:\n            pass\n\n        await runner.cleanup()\n\n    def _wait_next_notify(self) -> \"asyncio.Future[bool]\":\n        self._notify_waiter_done()\n\n        loop = self.loop\n        assert loop is not None\n        self._notify_waiter = waiter = loop.create_future()\n        self.loop.call_later(1.0, self._notify_waiter_done, waiter)\n\n        return waiter\n\n    def _notify_waiter_done(\n        self, waiter: Optional[\"asyncio.Future[bool]\"] = None\n    ) -> None:\n        if waiter is None:\n            waiter = self._notify_waiter\n        if waiter is not None:\n            set_result(waiter, True)\n\n        if waiter is self._notify_waiter:\n            self._notify_waiter = None\n\n    def init_signals(self) -> None:\n        # Set up signals through the event loop API.\n\n        self.loop.add_signal_handler(\n            signal.SIGQUIT, self.handle_quit, signal.SIGQUIT, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGTERM, self.handle_exit, signal.SIGTERM, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGINT, self.handle_quit, signal.SIGINT, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGWINCH, self.handle_winch, signal.SIGWINCH, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGUSR1, self.handle_usr1, signal.SIGUSR1, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGABRT, self.handle_abort, signal.SIGABRT, None\n        )\n\n        # Don't let SIGTERM and SIGUSR1 disturb active requests\n        # by interrupting system calls\n        signal.siginterrupt(signal.SIGTERM, False)\n        signal.siginterrupt(signal.SIGUSR1, False)\n        # Reset signals so Gunicorn doesn't swallow subprocess return codes\n        # See: https://github.com/aio-libs/aiohttp/issues/6130\n\n    def handle_quit(self, sig: int, frame: Optional[FrameType]) -> None:\n        self.alive = False\n\n        # worker_int callback\n        self.cfg.worker_int(self)\n\n        # wakeup closing process\n        self._notify_waiter_done()\n\n    def handle_abort(self, sig: int, frame: Optional[FrameType]) -> None:\n        self.alive = False\n        self.exit_code = 1\n        self.cfg.worker_abort(self)\n        sys.exit(1)\n\n    @staticmethod\n    def _create_ssl_context(cfg: Any) -> \"SSLContext\":\n        \"\"\"Creates SSLContext instance for usage in asyncio.create_server.\n\n        See ssl.SSLSocket.__init__ for more details.\n        \"\"\"\n        if ssl is None:  # pragma: no cover\n            raise RuntimeError(\"SSL is not supported.\")\n\n        ctx = ssl.SSLContext(cfg.ssl_version)\n        ctx.load_cert_chain(cfg.certfile, cfg.keyfile)\n        ctx.verify_mode = cfg.cert_reqs\n        if cfg.ca_certs:\n            ctx.load_verify_locations(cfg.ca_certs)\n        if cfg.ciphers:\n            ctx.set_ciphers(cfg.ciphers)\n        return ctx\n\n    def _get_valid_log_format(self, source_format: str) -> str:\n        if source_format == self.DEFAULT_GUNICORN_LOG_FORMAT:\n            return self.DEFAULT_AIOHTTP_LOG_FORMAT\n        elif re.search(r\"%\\([^\\)]+\\)\", source_format):\n            raise ValueError(\n                \"Gunicorn's style options in form of `%(name)s` are not \"\n                \"supported for the log formatting. Please use aiohttp's \"\n                \"format specification to configure access log formatting: \"\n                \"http://docs.aiohttp.org/en/stable/logging.html\"\n                \"#format-specification\"\n            )\n        else:\n            return source_format",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 32,
                                "end_lineno": 231,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "aiohttp/worker.py",
                            "type": "class",
                            "name": "GunicornWebWorker",
                            "content": "class GunicornWebWorker(base.Worker):  # type: ignore[misc,no-any-unimported]\n\n    DEFAULT_AIOHTTP_LOG_FORMAT = AccessLogger.LOG_FORMAT\n    DEFAULT_GUNICORN_LOG_FORMAT = GunicornAccessLogFormat.default\n\n    def __init__(self, *args: Any, **kw: Any) -> None:  # pragma: no cover\n        super().__init__(*args, **kw)\n\n        self._task: Optional[asyncio.Task[None]] = None\n        self.exit_code = 0\n        self._notify_waiter: Optional[asyncio.Future[bool]] = None\n\n    def init_process(self) -> None:\n        # create new event_loop after fork\n        asyncio.get_event_loop().close()\n\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(self.loop)\n\n        super().init_process()\n\n    def run(self) -> None:\n        self._task = self.loop.create_task(self._run())\n\n        try:  # ignore all finalization problems\n            self.loop.run_until_complete(self._task)\n        except Exception:\n            self.log.exception(\"Exception in gunicorn worker\")\n        self.loop.run_until_complete(self.loop.shutdown_asyncgens())\n        self.loop.close()\n\n        sys.exit(self.exit_code)\n\n    async def _run(self) -> None:\n        runner = None\n        if isinstance(self.wsgi, Application):\n            app = self.wsgi\n        elif asyncio.iscoroutinefunction(self.wsgi):\n            wsgi = await self.wsgi()\n            if isinstance(wsgi, web.AppRunner):\n                runner = wsgi\n                app = runner.app\n            else:\n                app = wsgi\n        else:\n            raise RuntimeError(\n                \"wsgi app should be either Application or \"\n                \"async function returning Application, got {}\".format(self.wsgi)\n            )\n\n        if runner is None:\n            access_log = self.log.access_log if self.cfg.accesslog else None\n            runner = web.AppRunner(\n                app,\n                logger=self.log,\n                keepalive_timeout=self.cfg.keepalive,\n                access_log=access_log,\n                access_log_format=self._get_valid_log_format(\n                    self.cfg.access_log_format\n                ),\n            )\n        await runner.setup()\n\n        ctx = self._create_ssl_context(self.cfg) if self.cfg.is_ssl else None\n\n        runner = runner\n        assert runner is not None\n        server = runner.server\n        assert server is not None\n        for sock in self.sockets:\n            site = web.SockSite(\n                runner,\n                sock,\n                ssl_context=ctx,\n                shutdown_timeout=self.cfg.graceful_timeout / 100 * 95,\n            )\n            await site.start()\n\n        # If our parent changed then we shut down.\n        pid = os.getpid()\n        try:\n            while self.alive:  # type: ignore[has-type]\n                self.notify()\n\n                cnt = server.requests_count\n                if self.cfg.max_requests and cnt > self.cfg.max_requests:\n                    self.alive = False\n                    self.log.info(\"Max requests, shutting down: %s\", self)\n\n                elif pid == os.getpid() and self.ppid != os.getppid():\n                    self.alive = False\n                    self.log.info(\"Parent changed, shutting down: %s\", self)\n                else:\n                    await self._wait_next_notify()\n        except BaseException:\n            pass\n\n        await runner.cleanup()\n\n    def _wait_next_notify(self) -> \"asyncio.Future[bool]\":\n        self._notify_waiter_done()\n\n        loop = self.loop\n        assert loop is not None\n        self._notify_waiter = waiter = loop.create_future()\n        self.loop.call_later(1.0, self._notify_waiter_done, waiter)\n\n        return waiter\n\n    def _notify_waiter_done(\n        self, waiter: Optional[\"asyncio.Future[bool]\"] = None\n    ) -> None:\n        if waiter is None:\n            waiter = self._notify_waiter\n        if waiter is not None:\n            set_result(waiter, True)\n\n        if waiter is self._notify_waiter:\n            self._notify_waiter = None\n\n    def init_signals(self) -> None:\n        # Set up signals through the event loop API.\n\n        self.loop.add_signal_handler(\n            signal.SIGQUIT, self.handle_quit, signal.SIGQUIT, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGTERM, self.handle_exit, signal.SIGTERM, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGINT, self.handle_quit, signal.SIGINT, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGWINCH, self.handle_winch, signal.SIGWINCH, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGUSR1, self.handle_usr1, signal.SIGUSR1, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGABRT, self.handle_abort, signal.SIGABRT, None\n        )\n\n        # Don't let SIGTERM and SIGUSR1 disturb active requests\n        # by interrupting system calls\n        signal.siginterrupt(signal.SIGTERM, False)\n        signal.siginterrupt(signal.SIGUSR1, False)\n        # Reset signals so Gunicorn doesn't swallow subprocess return codes\n        # See: https://github.com/aio-libs/aiohttp/issues/6130\n\n    def handle_quit(self, sig: int, frame: Optional[FrameType]) -> None:\n        self.alive = False\n\n        # worker_int callback\n        self.cfg.worker_int(self)\n\n        # wakeup closing process\n        self._notify_waiter_done()\n\n    def handle_abort(self, sig: int, frame: Optional[FrameType]) -> None:\n        self.alive = False\n        self.exit_code = 1\n        self.cfg.worker_abort(self)\n        sys.exit(1)\n\n    @staticmethod\n    def _create_ssl_context(cfg: Any) -> \"SSLContext\":\n        \"\"\"Creates SSLContext instance for usage in asyncio.create_server.\n\n        See ssl.SSLSocket.__init__ for more details.\n        \"\"\"\n        if ssl is None:  # pragma: no cover\n            raise RuntimeError(\"SSL is not supported.\")\n\n        ctx = ssl.SSLContext(cfg.ssl_version)\n        ctx.load_cert_chain(cfg.certfile, cfg.keyfile)\n        ctx.verify_mode = cfg.cert_reqs\n        if cfg.ca_certs:\n            ctx.load_verify_locations(cfg.ca_certs)\n        if cfg.ciphers:\n            ctx.set_ciphers(cfg.ciphers)\n        return ctx\n\n    def _get_valid_log_format(self, source_format: str) -> str:\n        if source_format == self.DEFAULT_GUNICORN_LOG_FORMAT:\n            return self.DEFAULT_AIOHTTP_LOG_FORMAT\n        elif re.search(r\"%\\([^\\)]+\\)\", source_format):\n            raise ValueError(\n                \"Gunicorn's style options in form of `%(name)s` are not \"\n                \"supported for the log formatting. Please use aiohttp's \"\n                \"format specification to configure access log formatting: \"\n                \"http://docs.aiohttp.org/en/stable/logging.html\"\n                \"#format-specification\"\n            )\n        else:\n            return source_format",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 32,
                            "end_lineno": 231,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        },
        {
            "old_file_content": "# Tests for aiohttp/worker.py\nimport asyncio\nimport os\nimport socket\nimport ssl\nfrom typing import TYPE_CHECKING, Callable, Dict, Optional\nfrom unittest import mock\n\nimport pytest\nfrom _pytest.fixtures import SubRequest\n\nfrom aiohttp import web\n\nif TYPE_CHECKING:\n    from aiohttp import worker as base_worker\nelse:\n    base_worker = pytest.importorskip(\"aiohttp.worker\")\n\n\ntry:\n    import uvloop\nexcept ImportError:\n    uvloop = None  # type: ignore[assignment]\n\n\nWRONG_LOG_FORMAT = '%a \"%{Referrer}i\" %(h)s %(l)s %s'\nACCEPTABLE_LOG_FORMAT = '%a \"%{Referrer}i\" %s'\n\n\nclass BaseTestWorker:\n    def __init__(self) -> None:\n        self.servers: Dict[object, object] = {}\n        self.exit_code = 0\n        self._notify_waiter: Optional[asyncio.Future[bool]] = None\n        self.cfg = mock.Mock()\n        self.cfg.graceful_timeout = 100\n        self.pid = \"pid\"\n        self.wsgi = web.Application()\n\n\nclass AsyncioWorker(BaseTestWorker, base_worker.GunicornWebWorker):  # type: ignore\n    pass\n\n\nPARAMS = [AsyncioWorker]\nif uvloop is not None:\n\n    class UvloopWorker(\n        BaseTestWorker, base_worker.GunicornUVLoopWebWorker  # type: ignore\n    ):\n        pass\n\n    PARAMS.append(UvloopWorker)\n\n\n@pytest.fixture(params=PARAMS)\ndef worker(\n    request: SubRequest, loop: asyncio.AbstractEventLoop\n) -> base_worker.GunicornWebWorker:\n    asyncio.set_event_loop(loop)\n    ret = request.param()\n    ret.notify = mock.Mock()\n    return ret  # type: ignore[no-any-return]\n\n\ndef test_init_process(worker: base_worker.GunicornWebWorker) -> None:\n    with mock.patch(\"aiohttp.worker.asyncio\") as m_asyncio:\n        try:\n            worker.init_process()\n        except TypeError:\n            pass\n\n        assert m_asyncio.get_event_loop.return_value.close.called\n        assert m_asyncio.new_event_loop.called\n        assert m_asyncio.set_event_loop.called\n\n\ndef test_run(\n    worker: base_worker.GunicornWebWorker, loop: asyncio.AbstractEventLoop\n) -> None:\n    worker.log = mock.Mock()\n    worker.cfg = mock.Mock()\n    worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT\n    worker.cfg.is_ssl = False\n    worker.sockets = []\n\n    worker.loop = loop\n    with pytest.raises(SystemExit):\n        worker.run()\n    worker.log.exception.assert_not_called()\n    assert loop.is_closed()\n\n\ndef test_run_async_factory(\n    worker: base_worker.GunicornWebWorker, loop: asyncio.AbstractEventLoop\n) -> None:\n    worker.log = mock.Mock()\n    worker.cfg = mock.Mock()\n    worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT\n    worker.cfg.is_ssl = False\n    worker.sockets = []\n    app = worker.wsgi\n\n    async def make_app() -> web.Application:\n        return app  # type: ignore[no-any-return]\n\n    worker.wsgi = make_app\n\n    worker.loop = loop\n    worker.alive = False\n    with pytest.raises(SystemExit):\n        worker.run()\n    worker.log.exception.assert_not_called()\n    assert loop.is_closed()\n\n\ndef test_run_not_app(\n    worker: base_worker.GunicornWebWorker, loop: asyncio.AbstractEventLoop\n) -> None:\n    worker.log = mock.Mock()\n    worker.cfg = mock.Mock()\n    worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT\n\n    worker.loop = loop\n    worker.wsgi = \"not-app\"\n    worker.alive = False\n    with pytest.raises(SystemExit):\n        worker.run()\n    worker.log.exception.assert_called_with(\"Exception in gunicorn worker\")\n    assert loop.is_closed()\n\n\ndef test_handle_abort(worker: base_worker.GunicornWebWorker) -> None:\n    with mock.patch(\"aiohttp.worker.sys\") as m_sys:\n        worker.handle_abort(0, None)\n        assert not worker.alive\n        assert worker.exit_code == 1\n        m_sys.exit.assert_called_with(1)\n\n\ndef test__wait_next_notify(worker: base_worker.GunicornWebWorker) -> None:\n    worker.loop = mloop = mock.create_autospec(asyncio.AbstractEventLoop)\n    with mock.patch.object(worker, \"_notify_waiter_done\", autospec=True):\n        fut = worker._wait_next_notify()\n\n        assert worker._notify_waiter == fut\n        mloop.call_later.assert_called_with(1.0, worker._notify_waiter_done, fut)\n\n\ndef test__notify_waiter_done(worker: base_worker.GunicornWebWorker) -> None:\n    worker._notify_waiter = None\n    worker._notify_waiter_done()\n    assert worker._notify_waiter is None\n\n    waiter = worker._notify_waiter = mock.Mock()\n    worker._notify_waiter.done.return_value = False\n    worker._notify_waiter_done()\n\n    assert worker._notify_waiter is None\n    waiter.set_result.assert_called_with(True)\n\n\ndef test__notify_waiter_done_explicit_waiter(\n    worker: base_worker.GunicornWebWorker,\n) -> None:\n    worker._notify_waiter = None\n    assert worker._notify_waiter is None\n\n    waiter = worker._notify_waiter = mock.Mock()\n    waiter.done.return_value = False\n    waiter2 = worker._notify_waiter = mock.Mock()\n    worker._notify_waiter_done(waiter)\n\n    assert worker._notify_waiter is waiter2\n    waiter.set_result.assert_called_with(True)\n    assert not waiter2.set_result.called\n\n\ndef test_init_signals(worker: base_worker.GunicornWebWorker) -> None:\n    worker.loop = mock.Mock()\n    worker.init_signals()\n    assert worker.loop.add_signal_handler.called\n\n\n@pytest.mark.parametrize(\n    \"source,result\",\n    [\n        (ACCEPTABLE_LOG_FORMAT, ACCEPTABLE_LOG_FORMAT),\n        (\n            AsyncioWorker.DEFAULT_GUNICORN_LOG_FORMAT,\n            AsyncioWorker.DEFAULT_AIOHTTP_LOG_FORMAT,\n        ),\n    ],\n)\ndef test__get_valid_log_format_ok(\n    worker: base_worker.GunicornWebWorker, source: str, result: str\n) -> None:\n    assert result == worker._get_valid_log_format(source)\n\n\ndef test__get_valid_log_format_exc(worker: base_worker.GunicornWebWorker) -> None:\n    with pytest.raises(ValueError) as exc:\n        worker._get_valid_log_format(WRONG_LOG_FORMAT)\n    assert \"%(name)s\" in str(exc.value)\n\n\nasync def test__run_ok_parent_changed(\n    worker: base_worker.GunicornWebWorker,\n    loop: asyncio.AbstractEventLoop,\n    aiohttp_unused_port: Callable[[], int],\n) -> None:\n    worker.ppid = 0\n    worker.alive = True\n    sock = socket.socket()\n    addr = (\"localhost\", aiohttp_unused_port())\n    sock.bind(addr)\n    worker.sockets = [sock]\n    worker.log = mock.Mock()\n    worker.loop = loop\n    worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT\n    worker.cfg.max_requests = 0\n    worker.cfg.is_ssl = False\n\n    await worker._run()\n\n    worker.notify.assert_called_with()\n    worker.log.info.assert_called_with(\"Parent changed, shutting down: %s\", worker)\n\n\nasync def test__run_exc(\n    worker: base_worker.GunicornWebWorker,\n    loop: asyncio.AbstractEventLoop,\n    aiohttp_unused_port: Callable[[], int],\n) -> None:\n    worker.ppid = os.getppid()\n    worker.alive = True\n    sock = socket.socket()\n    addr = (\"localhost\", aiohttp_unused_port())\n    sock.bind(addr)\n    worker.sockets = [sock]\n    worker.log = mock.Mock()\n    worker.loop = loop\n    worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT\n    worker.cfg.max_requests = 0\n    worker.cfg.is_ssl = False\n\n    def raiser() -> None:\n        waiter = worker._notify_waiter\n        worker.alive = False\n        assert waiter is not None\n        waiter.set_exception(RuntimeError())\n\n    loop.call_later(0.1, raiser)\n    await worker._run()\n\n    worker.notify.assert_called_with()\n\n\ndef test__create_ssl_context_without_certs_and_ciphers(\n    worker: base_worker.GunicornWebWorker,\n    tls_certificate_pem_path: str,\n) -> None:\n    worker.cfg.ssl_version = ssl.PROTOCOL_TLS_CLIENT\n    worker.cfg.cert_reqs = ssl.CERT_OPTIONAL\n    worker.cfg.certfile = tls_certificate_pem_path\n    worker.cfg.keyfile = tls_certificate_pem_path\n    worker.cfg.ca_certs = None\n    worker.cfg.ciphers = None\n    ctx = worker._create_ssl_context(worker.cfg)\n    assert isinstance(ctx, ssl.SSLContext)\n\n\ndef test__create_ssl_context_with_ciphers(\n    worker: base_worker.GunicornWebWorker,\n    tls_certificate_pem_path: str,\n) -> None:\n    worker.cfg.ssl_version = ssl.PROTOCOL_TLS_CLIENT\n    worker.cfg.cert_reqs = ssl.CERT_OPTIONAL\n    worker.cfg.certfile = tls_certificate_pem_path\n    worker.cfg.keyfile = tls_certificate_pem_path\n    worker.cfg.ca_certs = None\n    worker.cfg.ciphers = \"3DES PSK\"\n    ctx = worker._create_ssl_context(worker.cfg)\n    assert isinstance(ctx, ssl.SSLContext)\n\n\ndef test__create_ssl_context_with_ca_certs(\n    worker: base_worker.GunicornWebWorker,\n    tls_ca_certificate_pem_path: str,\n    tls_certificate_pem_path: str,\n) -> None:\n    worker.cfg.ssl_version = ssl.PROTOCOL_TLS_CLIENT\n    worker.cfg.cert_reqs = ssl.CERT_OPTIONAL\n    worker.cfg.certfile = tls_certificate_pem_path\n    worker.cfg.keyfile = tls_certificate_pem_path\n    worker.cfg.ca_certs = tls_ca_certificate_pem_path\n    worker.cfg.ciphers = None\n    ctx = worker._create_ssl_context(worker.cfg)\n    assert isinstance(ctx, ssl.SSLContext)\n",
            "new_file_content": "# Tests for aiohttp/worker.py\nimport asyncio\nimport os\nimport socket\nimport ssl\nfrom typing import TYPE_CHECKING, Callable, Dict, Optional\nfrom unittest import mock\n\nimport pytest\nfrom _pytest.fixtures import SubRequest\n\nfrom aiohttp import web\n\nif TYPE_CHECKING:\n    from aiohttp import worker as base_worker\nelse:\n    base_worker = pytest.importorskip(\"aiohttp.worker\")\n\n\ntry:\n    import uvloop\nexcept ImportError:\n    uvloop = None  # type: ignore[assignment]\n\n\nWRONG_LOG_FORMAT = '%a \"%{Referrer}i\" %(h)s %(l)s %s'\nACCEPTABLE_LOG_FORMAT = '%a \"%{Referrer}i\" %s'\n\n\nclass BaseTestWorker:\n    def __init__(self) -> None:\n        self.servers: Dict[object, object] = {}\n        self.exit_code = 0\n        self._notify_waiter: Optional[asyncio.Future[bool]] = None\n        self.cfg = mock.Mock()\n        self.cfg.graceful_timeout = 100\n        self.pid = \"pid\"\n        self.wsgi = web.Application()\n\n\nclass AsyncioWorker(BaseTestWorker, base_worker.GunicornWebWorker):  # type: ignore\n    pass\n\n\nPARAMS = [AsyncioWorker]\nif uvloop is not None:\n\n    class UvloopWorker(\n        BaseTestWorker, base_worker.GunicornUVLoopWebWorker  # type: ignore\n    ):\n        pass\n\n    PARAMS.append(UvloopWorker)\n\n\n@pytest.fixture(params=PARAMS)\ndef worker(\n    request: SubRequest, loop: asyncio.AbstractEventLoop\n) -> base_worker.GunicornWebWorker:\n    asyncio.set_event_loop(loop)\n    ret = request.param()\n    ret.notify = mock.Mock()\n    return ret  # type: ignore[no-any-return]\n\n\ndef test_init_process(worker: base_worker.GunicornWebWorker) -> None:\n    with mock.patch(\"aiohttp.worker.asyncio\") as m_asyncio:\n        try:\n            worker.init_process()\n        except TypeError:\n            pass\n\n        assert m_asyncio.get_event_loop.return_value.close.called\n        assert m_asyncio.new_event_loop.called\n        assert m_asyncio.set_event_loop.called\n\n\ndef test_run(\n    worker: base_worker.GunicornWebWorker, loop: asyncio.AbstractEventLoop\n) -> None:\n    worker.log = mock.Mock()\n    worker.cfg = mock.Mock()\n    worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT\n    worker.cfg.is_ssl = False\n    worker.sockets = []\n\n    worker.loop = loop\n    with pytest.raises(SystemExit):\n        worker.run()\n    worker.log.exception.assert_not_called()\n    assert loop.is_closed()\n\n\ndef test_run_async_factory(\n    worker: base_worker.GunicornWebWorker, loop: asyncio.AbstractEventLoop\n) -> None:\n    worker.log = mock.Mock()\n    worker.cfg = mock.Mock()\n    worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT\n    worker.cfg.is_ssl = False\n    worker.sockets = []\n    app = worker.wsgi\n\n    async def make_app() -> web.Application:\n        return app  # type: ignore[no-any-return]\n\n    worker.wsgi = make_app\n\n    worker.loop = loop\n    worker.alive = False\n    with pytest.raises(SystemExit):\n        worker.run()\n    worker.log.exception.assert_not_called()\n    assert loop.is_closed()\n\n\ndef test_run_not_app(\n    worker: base_worker.GunicornWebWorker, loop: asyncio.AbstractEventLoop\n) -> None:\n    worker.log = mock.Mock()\n    worker.cfg = mock.Mock()\n    worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT\n\n    worker.loop = loop\n    worker.wsgi = \"not-app\"\n    worker.alive = False\n    with pytest.raises(SystemExit):\n        worker.run()\n    worker.log.exception.assert_called_with(\"Exception in gunicorn worker\")\n    assert loop.is_closed()\n\n\ndef test_handle_abort(worker: base_worker.GunicornWebWorker) -> None:\n    with mock.patch(\"aiohttp.worker.sys\") as m_sys:\n        worker.handle_abort(0, None)\n        assert not worker.alive\n        assert worker.exit_code == 1\n        m_sys.exit.assert_called_with(1)\n\n\ndef test__wait_next_notify(worker: base_worker.GunicornWebWorker) -> None:\n    worker.loop = mloop = mock.create_autospec(asyncio.AbstractEventLoop)\n    with mock.patch.object(worker, \"_notify_waiter_done\", autospec=True):\n        fut = worker._wait_next_notify()\n\n        assert worker._notify_waiter == fut\n        mloop.call_later.assert_called_with(1.0, worker._notify_waiter_done, fut)\n\n\ndef test__notify_waiter_done(worker: base_worker.GunicornWebWorker) -> None:\n    worker._notify_waiter = None\n    worker._notify_waiter_done()\n    assert worker._notify_waiter is None\n\n    waiter = worker._notify_waiter = mock.Mock()\n    worker._notify_waiter.done.return_value = False\n    worker._notify_waiter_done()\n\n    assert worker._notify_waiter is None\n    waiter.set_result.assert_called_with(True)\n\n\ndef test__notify_waiter_done_explicit_waiter(\n    worker: base_worker.GunicornWebWorker,\n) -> None:\n    worker._notify_waiter = None\n    assert worker._notify_waiter is None\n\n    waiter = worker._notify_waiter = mock.Mock()\n    waiter.done.return_value = False\n    waiter2 = worker._notify_waiter = mock.Mock()\n    worker._notify_waiter_done(waiter)\n\n    assert worker._notify_waiter is waiter2\n    waiter.set_result.assert_called_with(True)\n    assert not waiter2.set_result.called\n\n\ndef test_init_signals(worker: base_worker.GunicornWebWorker) -> None:\n    worker.loop = mock.Mock()\n    worker.init_signals()\n    assert worker.loop.add_signal_handler.called\n\n\n@pytest.mark.parametrize(\n    \"source,result\",\n    [\n        (ACCEPTABLE_LOG_FORMAT, ACCEPTABLE_LOG_FORMAT),\n        (\n            AsyncioWorker.DEFAULT_GUNICORN_LOG_FORMAT,\n            AsyncioWorker.DEFAULT_AIOHTTP_LOG_FORMAT,\n        ),\n    ],\n)\ndef test__get_valid_log_format_ok(\n    worker: base_worker.GunicornWebWorker, source: str, result: str\n) -> None:\n    assert result == worker._get_valid_log_format(source)\n\n\ndef test__get_valid_log_format_exc(worker: base_worker.GunicornWebWorker) -> None:\n    with pytest.raises(ValueError) as exc:\n        worker._get_valid_log_format(WRONG_LOG_FORMAT)\n    assert \"%(name)s\" in str(exc.value)\n\n\nasync def test__run_ok_parent_changed(\n    worker: base_worker.GunicornWebWorker,\n    loop: asyncio.AbstractEventLoop,\n    aiohttp_unused_port: Callable[[], int],\n) -> None:\n    worker.ppid = 0\n    worker.alive = True\n    sock = socket.socket()\n    addr = (\"localhost\", aiohttp_unused_port())\n    sock.bind(addr)\n    worker.sockets = [sock]\n    worker.log = mock.Mock()\n    worker.loop = loop\n    worker.max_requests = 0\n    worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT\n    worker.cfg.is_ssl = False\n\n    await worker._run()\n\n    worker.notify.assert_called_with()\n    worker.log.info.assert_called_with(\"Parent changed, shutting down: %s\", worker)\n\n\nasync def test__run_exc(\n    worker: base_worker.GunicornWebWorker,\n    loop: asyncio.AbstractEventLoop,\n    aiohttp_unused_port: Callable[[], int],\n) -> None:\n    worker.ppid = os.getppid()\n    worker.alive = True\n    sock = socket.socket()\n    addr = (\"localhost\", aiohttp_unused_port())\n    sock.bind(addr)\n    worker.sockets = [sock]\n    worker.log = mock.Mock()\n    worker.loop = loop\n    worker.max_requests = 0\n    worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT\n    worker.cfg.is_ssl = False\n\n    def raiser() -> None:\n        waiter = worker._notify_waiter\n        worker.alive = False\n        assert waiter is not None\n        waiter.set_exception(RuntimeError())\n\n    loop.call_later(0.1, raiser)\n    await worker._run()\n\n    worker.notify.assert_called_with()\n\n\ndef test__create_ssl_context_without_certs_and_ciphers(\n    worker: base_worker.GunicornWebWorker,\n    tls_certificate_pem_path: str,\n) -> None:\n    worker.cfg.ssl_version = ssl.PROTOCOL_TLS_CLIENT\n    worker.cfg.cert_reqs = ssl.CERT_OPTIONAL\n    worker.cfg.certfile = tls_certificate_pem_path\n    worker.cfg.keyfile = tls_certificate_pem_path\n    worker.cfg.ca_certs = None\n    worker.cfg.ciphers = None\n    ctx = worker._create_ssl_context(worker.cfg)\n    assert isinstance(ctx, ssl.SSLContext)\n\n\ndef test__create_ssl_context_with_ciphers(\n    worker: base_worker.GunicornWebWorker,\n    tls_certificate_pem_path: str,\n) -> None:\n    worker.cfg.ssl_version = ssl.PROTOCOL_TLS_CLIENT\n    worker.cfg.cert_reqs = ssl.CERT_OPTIONAL\n    worker.cfg.certfile = tls_certificate_pem_path\n    worker.cfg.keyfile = tls_certificate_pem_path\n    worker.cfg.ca_certs = None\n    worker.cfg.ciphers = \"3DES PSK\"\n    ctx = worker._create_ssl_context(worker.cfg)\n    assert isinstance(ctx, ssl.SSLContext)\n\n\ndef test__create_ssl_context_with_ca_certs(\n    worker: base_worker.GunicornWebWorker,\n    tls_ca_certificate_pem_path: str,\n    tls_certificate_pem_path: str,\n) -> None:\n    worker.cfg.ssl_version = ssl.PROTOCOL_TLS_CLIENT\n    worker.cfg.cert_reqs = ssl.CERT_OPTIONAL\n    worker.cfg.certfile = tls_certificate_pem_path\n    worker.cfg.keyfile = tls_certificate_pem_path\n    worker.cfg.ca_certs = tls_ca_certificate_pem_path\n    worker.cfg.ciphers = None\n    ctx = worker._create_ssl_context(worker.cfg)\n    assert isinstance(ctx, ssl.SSLContext)\n",
            "header": {
                "file": {
                    "path": "tests/test_worker.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "2050e995",
                "new_commit_hash": "c2ec4710",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/tests/test_worker.py"
            },
            "plus_file": {
                "path": "b/tests/test_worker.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 217,
                            "length": 8
                        },
                        "new_range": {
                            "start": 217,
                            "length": 8
                        },
                        "section": "async def test__run_ok_parent_changed("
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "    worker.sockets = [sock]",
                                "type": "context"
                            },
                            {
                                "content": "    worker.log = mock.Mock()",
                                "type": "context"
                            },
                            {
                                "content": "    worker.loop = loop",
                                "type": "context"
                            },
                            {
                                "content": "    worker.max_requests = 0",
                                "type": "added"
                            },
                            {
                                "content": "    worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT",
                                "type": "context"
                            },
                            {
                                "content": "    worker.cfg.max_requests = 0",
                                "type": "deleted"
                            },
                            {
                                "content": "    worker.cfg.is_ssl = False",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    await worker._run()",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "tests/test_worker.py",
                            "type": "function",
                            "name": "test__run_ok_parent_changed",
                            "content": "async def test__run_ok_parent_changed(\n    worker: base_worker.GunicornWebWorker,\n    loop: asyncio.AbstractEventLoop,\n    aiohttp_unused_port: Callable[[], int],\n) -> None:\n    worker.ppid = 0\n    worker.alive = True\n    sock = socket.socket()\n    addr = (\"localhost\", aiohttp_unused_port())\n    sock.bind(addr)\n    worker.sockets = [sock]\n    worker.log = mock.Mock()\n    worker.loop = loop\n    worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT\n    worker.cfg.max_requests = 0\n    worker.cfg.is_ssl = False\n\n    await worker._run()\n\n    worker.notify.assert_called_with()\n    worker.log.info.assert_called_with(\"Parent changed, shutting down: %s\", worker)",
                            "ast_type_str": "AsyncFunctionDef",
                            "start_lineno": 207,
                            "end_lineno": 227,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 240,
                            "length": 8
                        },
                        "new_range": {
                            "start": 240,
                            "length": 8
                        },
                        "section": "async def test__run_exc("
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "    worker.sockets = [sock]",
                                "type": "context"
                            },
                            {
                                "content": "    worker.log = mock.Mock()",
                                "type": "context"
                            },
                            {
                                "content": "    worker.loop = loop",
                                "type": "context"
                            },
                            {
                                "content": "    worker.max_requests = 0",
                                "type": "added"
                            },
                            {
                                "content": "    worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT",
                                "type": "context"
                            },
                            {
                                "content": "    worker.cfg.max_requests = 0",
                                "type": "deleted"
                            },
                            {
                                "content": "    worker.cfg.is_ssl = False",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def raiser() -> None:",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "tests/test_worker.py",
                            "type": "function",
                            "name": "test__run_exc",
                            "content": "async def test__run_exc(\n    worker: base_worker.GunicornWebWorker,\n    loop: asyncio.AbstractEventLoop,\n    aiohttp_unused_port: Callable[[], int],\n) -> None:\n    worker.ppid = os.getppid()\n    worker.alive = True\n    sock = socket.socket()\n    addr = (\"localhost\", aiohttp_unused_port())\n    sock.bind(addr)\n    worker.sockets = [sock]\n    worker.log = mock.Mock()\n    worker.loop = loop\n    worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT\n    worker.cfg.max_requests = 0\n    worker.cfg.is_ssl = False\n\n    def raiser() -> None:\n        waiter = worker._notify_waiter\n        worker.alive = False\n        assert waiter is not None\n        waiter.set_exception(RuntimeError())\n\n    loop.call_later(0.1, raiser)\n    await worker._run()\n\n    worker.notify.assert_called_with()",
                            "ast_type_str": "AsyncFunctionDef",
                            "start_lineno": 230,
                            "end_lineno": 256,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        }
    ],
    "old_commit_hash": "800c7929cae8d9bb4605783a4d3b45ee9480840f^",
    "new_commit_hash": "800c7929cae8d9bb4605783a4d3b45ee9480840f",
    "commit_message": "[PR #7518/8bd42e74 backport][3.9] Fix GunicornWebWorker max_requests_jitter not work (#7520)\n\n**This is a backport of PR #7518 as merged into master\r\n(8bd42e742acc825e8b2f170c04216da3c767f56e).**\r\n\r\n<!-- Thank you for your contribution! -->\r\n\r\n## What do these changes do?\r\n\r\n<!-- Please give a short brief about these changes. -->\r\n\r\n`GunicornWebWorker` use `self.cfg.max_requests` which is not add jitter,\r\nfrom\r\nhttps://github.com/benoitc/gunicorn/blob/master/gunicorn/workers/base.py#L56-L60,\r\nthe correct way is to use `sef.max_requests`\r\n\r\n## Are there changes in behavior for the user?\r\n\r\n<!-- Outline any notable behaviour for the end users. -->\r\n\r\nAfter the PR is merged, the max-requests-jitter parameter of Gunicorn\r\ncan take effect.\r\n\r\n## Related issue number\r\n\r\n<!-- Are there any issues opened that will be resolved by merging this\r\nchange? -->\r\n\r\n## Checklist\r\n\r\n- [x] I think the code is well written\r\n- [x] Unit tests for the changes exist\r\n- [ ] Documentation reflects the changes\r\n- [ ] If you provide code modification, please add yourself to\r\n`CONTRIBUTORS.txt`\r\n  * The format is &lt;Name&gt; &lt;Surname&gt;.\r\n  * Please keep alphabetical order, the file is sorted by names.\r\n- [x] Add a new news fragment into the `CHANGES` folder\r\n  * name it `<issue_id>.<type>` for example (588.bugfix)\r\n* if you don't have an `issue_id` change it to the pr id after creating\r\nthe pr\r\n  * ensure type is one of the following:\r\n    * `.feature`: Signifying a new feature.\r\n    * `.bugfix`: Signifying a bug fix.\r\n    * `.doc`: Signifying a documentation improvement.\r\n    * `.removal`: Signifying a deprecation or removal of public API.\r\n* `.misc`: A ticket has been closed, but it is not of interest to users.\r\n* Make sure to use full sentences with correct case and punctuation, for\r\nexample: \"Fix issue with non-ascii contents in doctest text files.\"\r\n\r\nCo-authored-by: phyng <phyngk@gmail.com>",
    "commit_date": "2023-08-12T15:57:31Z",
    "metadata": {}
}
{
    "repo_name": "aiohttp",
    "new_commit_hash": "800c7929cae8d9bb4605783a4d3b45ee9480840f",
    "test_file_codes": [
        "# Tests for aiohttp/worker.py\nimport asyncio\nimport os\nimport socket\nimport ssl\nfrom typing import TYPE_CHECKING, Callable, Dict, Optional\nfrom unittest import mock\n\nimport pytest\nfrom _pytest.fixtures import SubRequest\n\nfrom aiohttp import web\n\nif TYPE_CHECKING:\n    from aiohttp import worker as base_worker\nelse:\n    base_worker = pytest.importorskip(\"aiohttp.worker\")\n\n\ntry:\n    import uvloop\nexcept ImportError:\n    uvloop = None  # type: ignore[assignment]\n\n\nWRONG_LOG_FORMAT = '%a \"%{Referrer}i\" %(h)s %(l)s %s'\nACCEPTABLE_LOG_FORMAT = '%a \"%{Referrer}i\" %s'\n\n\nclass BaseTestWorker:\n    def __init__(self) -> None:\n        self.servers: Dict[object, object] = {}\n        self.exit_code = 0\n        self._notify_waiter: Optional[asyncio.Future[bool]] = None\n        self.cfg = mock.Mock()\n        self.cfg.graceful_timeout = 100\n        self.pid = \"pid\"\n        self.wsgi = web.Application()\n\n\nclass AsyncioWorker(BaseTestWorker, base_worker.GunicornWebWorker):  # type: ignore\n    pass\n\n\nPARAMS = [AsyncioWorker]\nif uvloop is not None:\n\n    class UvloopWorker(\n        BaseTestWorker, base_worker.GunicornUVLoopWebWorker  # type: ignore\n    ):\n        pass\n\n    PARAMS.append(UvloopWorker)\n\n\n@pytest.fixture(params=PARAMS)\ndef worker(\n    request: SubRequest, loop: asyncio.AbstractEventLoop\n) -> base_worker.GunicornWebWorker:\n    asyncio.set_event_loop(loop)\n    ret = request.param()\n    ret.notify = mock.Mock()\n    return ret  # type: ignore[no-any-return]\n\n\ndef test_init_process(worker: base_worker.GunicornWebWorker) -> None:\n    with mock.patch(\"aiohttp.worker.asyncio\") as m_asyncio:\n        try:\n            worker.init_process()\n        except TypeError:\n            pass\n\n        assert m_asyncio.get_event_loop.return_value.close.called\n        assert m_asyncio.new_event_loop.called\n        assert m_asyncio.set_event_loop.called\n\n\ndef test_run(\n    worker: base_worker.GunicornWebWorker, loop: asyncio.AbstractEventLoop\n) -> None:\n    worker.log = mock.Mock()\n    worker.cfg = mock.Mock()\n    worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT\n    worker.cfg.is_ssl = False\n    worker.sockets = []\n\n    worker.loop = loop\n    with pytest.raises(SystemExit):\n        worker.run()\n    worker.log.exception.assert_not_called()\n    assert loop.is_closed()\n\n\ndef test_run_async_factory(\n    worker: base_worker.GunicornWebWorker, loop: asyncio.AbstractEventLoop\n) -> None:\n    worker.log = mock.Mock()\n    worker.cfg = mock.Mock()\n    worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT\n    worker.cfg.is_ssl = False\n    worker.sockets = []\n    app = worker.wsgi\n\n    async def make_app() -> web.Application:\n        return app  # type: ignore[no-any-return]\n\n    worker.wsgi = make_app\n\n    worker.loop = loop\n    worker.alive = False\n    with pytest.raises(SystemExit):\n        worker.run()\n    worker.log.exception.assert_not_called()\n    assert loop.is_closed()\n\n\ndef test_run_not_app(\n    worker: base_worker.GunicornWebWorker, loop: asyncio.AbstractEventLoop\n) -> None:\n    worker.log = mock.Mock()\n    worker.cfg = mock.Mock()\n    worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT\n\n    worker.loop = loop\n    worker.wsgi = \"not-app\"\n    worker.alive = False\n    with pytest.raises(SystemExit):\n        worker.run()\n    worker.log.exception.assert_called_with(\"Exception in gunicorn worker\")\n    assert loop.is_closed()\n\n\ndef test_handle_abort(worker: base_worker.GunicornWebWorker) -> None:\n    with mock.patch(\"aiohttp.worker.sys\") as m_sys:\n        worker.handle_abort(0, None)\n        assert not worker.alive\n        assert worker.exit_code == 1\n        m_sys.exit.assert_called_with(1)\n\n\ndef test__wait_next_notify(worker: base_worker.GunicornWebWorker) -> None:\n    worker.loop = mloop = mock.create_autospec(asyncio.AbstractEventLoop)\n    with mock.patch.object(worker, \"_notify_waiter_done\", autospec=True):\n        fut = worker._wait_next_notify()\n\n        assert worker._notify_waiter == fut\n        mloop.call_later.assert_called_with(1.0, worker._notify_waiter_done, fut)\n\n\ndef test__notify_waiter_done(worker: base_worker.GunicornWebWorker) -> None:\n    worker._notify_waiter = None\n    worker._notify_waiter_done()\n    assert worker._notify_waiter is None\n\n    waiter = worker._notify_waiter = mock.Mock()\n    worker._notify_waiter.done.return_value = False\n    worker._notify_waiter_done()\n\n    assert worker._notify_waiter is None\n    waiter.set_result.assert_called_with(True)\n\n\ndef test__notify_waiter_done_explicit_waiter(\n    worker: base_worker.GunicornWebWorker,\n) -> None:\n    worker._notify_waiter = None\n    assert worker._notify_waiter is None\n\n    waiter = worker._notify_waiter = mock.Mock()\n    waiter.done.return_value = False\n    waiter2 = worker._notify_waiter = mock.Mock()\n    worker._notify_waiter_done(waiter)\n\n    assert worker._notify_waiter is waiter2\n    waiter.set_result.assert_called_with(True)\n    assert not waiter2.set_result.called\n\n\ndef test_init_signals(worker: base_worker.GunicornWebWorker) -> None:\n    worker.loop = mock.Mock()\n    worker.init_signals()\n    assert worker.loop.add_signal_handler.called\n\n\n@pytest.mark.parametrize(\n    \"source,result\",\n    [\n        (ACCEPTABLE_LOG_FORMAT, ACCEPTABLE_LOG_FORMAT),\n        (\n            AsyncioWorker.DEFAULT_GUNICORN_LOG_FORMAT,\n            AsyncioWorker.DEFAULT_AIOHTTP_LOG_FORMAT,\n        ),\n    ],\n)\ndef test__get_valid_log_format_ok(\n    worker: base_worker.GunicornWebWorker, source: str, result: str\n) -> None:\n    assert result == worker._get_valid_log_format(source)\n\n\ndef test__get_valid_log_format_exc(worker: base_worker.GunicornWebWorker) -> None:\n    with pytest.raises(ValueError) as exc:\n        worker._get_valid_log_format(WRONG_LOG_FORMAT)\n    assert \"%(name)s\" in str(exc.value)\n\n\nasync def test__run_ok_parent_changed(\n    worker: base_worker.GunicornWebWorker,\n    loop: asyncio.AbstractEventLoop,\n    aiohttp_unused_port: Callable[[], int],\n) -> None:\n    worker.ppid = 0\n    worker.alive = True\n    sock = socket.socket()\n    addr = (\"localhost\", aiohttp_unused_port())\n    sock.bind(addr)\n    worker.sockets = [sock]\n    worker.log = mock.Mock()\n    worker.loop = loop\n    worker.max_requests = 0\n    worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT\n    worker.cfg.is_ssl = False\n\n    await worker._run()\n\n    worker.notify.assert_called_with()\n    worker.log.info.assert_called_with(\"Parent changed, shutting down: %s\", worker)\n\n\nasync def test__run_exc(\n    worker: base_worker.GunicornWebWorker,\n    loop: asyncio.AbstractEventLoop,\n    aiohttp_unused_port: Callable[[], int],\n) -> None:\n    worker.ppid = os.getppid()\n    worker.alive = True\n    sock = socket.socket()\n    addr = (\"localhost\", aiohttp_unused_port())\n    sock.bind(addr)\n    worker.sockets = [sock]\n    worker.log = mock.Mock()\n    worker.loop = loop\n    worker.max_requests = 0\n    worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT\n    worker.cfg.is_ssl = False\n\n    def raiser() -> None:\n        waiter = worker._notify_waiter\n        worker.alive = False\n        assert waiter is not None\n        waiter.set_exception(RuntimeError())\n\n    loop.call_later(0.1, raiser)\n    await worker._run()\n\n    worker.notify.assert_called_with()\n\n\ndef test__create_ssl_context_without_certs_and_ciphers(\n    worker: base_worker.GunicornWebWorker,\n    tls_certificate_pem_path: str,\n) -> None:\n    worker.cfg.ssl_version = ssl.PROTOCOL_TLS_CLIENT\n    worker.cfg.cert_reqs = ssl.CERT_OPTIONAL\n    worker.cfg.certfile = tls_certificate_pem_path\n    worker.cfg.keyfile = tls_certificate_pem_path\n    worker.cfg.ca_certs = None\n    worker.cfg.ciphers = None\n    ctx = worker._create_ssl_context(worker.cfg)\n    assert isinstance(ctx, ssl.SSLContext)\n\n\ndef test__create_ssl_context_with_ciphers(\n    worker: base_worker.GunicornWebWorker,\n    tls_certificate_pem_path: str,\n) -> None:\n    worker.cfg.ssl_version = ssl.PROTOCOL_TLS_CLIENT\n    worker.cfg.cert_reqs = ssl.CERT_OPTIONAL\n    worker.cfg.certfile = tls_certificate_pem_path\n    worker.cfg.keyfile = tls_certificate_pem_path\n    worker.cfg.ca_certs = None\n    worker.cfg.ciphers = \"3DES PSK\"\n    ctx = worker._create_ssl_context(worker.cfg)\n    assert isinstance(ctx, ssl.SSLContext)\n\n\ndef test__create_ssl_context_with_ca_certs(\n    worker: base_worker.GunicornWebWorker,\n    tls_ca_certificate_pem_path: str,\n    tls_certificate_pem_path: str,\n) -> None:\n    worker.cfg.ssl_version = ssl.PROTOCOL_TLS_CLIENT\n    worker.cfg.cert_reqs = ssl.CERT_OPTIONAL\n    worker.cfg.certfile = tls_certificate_pem_path\n    worker.cfg.keyfile = tls_certificate_pem_path\n    worker.cfg.ca_certs = tls_ca_certificate_pem_path\n    worker.cfg.ciphers = None\n    ctx = worker._create_ssl_context(worker.cfg)\n    assert isinstance(ctx, ssl.SSLContext)\n",
        "import asyncio\nimport os\nimport socket\nimport ssl\nimport sys\nfrom hashlib import md5, sha256\nfrom pathlib import Path\nfrom tempfile import TemporaryDirectory\nfrom uuid import uuid4\n\nimport pytest\n\nfrom aiohttp.test_utils import loop_context\n\ntry:\n    import trustme\n\n    # Check if the CA is available in runtime, MacOS on Py3.10 fails somehow\n    trustme.CA()\n\n    TRUSTME: bool = True\nexcept ImportError:\n    TRUSTME = False\n\npytest_plugins = [\"aiohttp.pytest_plugin\", \"pytester\"]\n\nIS_HPUX = sys.platform.startswith(\"hp-ux\")\nIS_LINUX = sys.platform.startswith(\"linux\")\n\n\n@pytest.fixture\ndef tls_certificate_authority():\n    if not TRUSTME:\n        pytest.xfail(\"trustme is not supported\")\n    return trustme.CA()\n\n\n@pytest.fixture\ndef tls_certificate(tls_certificate_authority):\n    return tls_certificate_authority.issue_cert(\n        \"localhost\",\n        \"127.0.0.1\",\n        \"::1\",\n    )\n\n\n@pytest.fixture\ndef ssl_ctx(tls_certificate):\n    ssl_ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)\n    tls_certificate.configure_cert(ssl_ctx)\n    return ssl_ctx\n\n\n@pytest.fixture\ndef client_ssl_ctx(tls_certificate_authority):\n    ssl_ctx = ssl.create_default_context(purpose=ssl.Purpose.SERVER_AUTH)\n    tls_certificate_authority.configure_trust(ssl_ctx)\n    return ssl_ctx\n\n\n@pytest.fixture\ndef tls_ca_certificate_pem_path(tls_certificate_authority):\n    with tls_certificate_authority.cert_pem.tempfile() as ca_cert_pem:\n        yield ca_cert_pem\n\n\n@pytest.fixture\ndef tls_certificate_pem_path(tls_certificate):\n    with tls_certificate.private_key_and_cert_chain_pem.tempfile() as cert_pem:\n        yield cert_pem\n\n\n@pytest.fixture\ndef tls_certificate_pem_bytes(tls_certificate):\n    return tls_certificate.cert_chain_pems[0].bytes()\n\n\n@pytest.fixture\ndef tls_certificate_fingerprint_sha256(tls_certificate_pem_bytes):\n    tls_cert_der = ssl.PEM_cert_to_DER_cert(tls_certificate_pem_bytes.decode())\n    return sha256(tls_cert_der).digest()\n\n\n@pytest.fixture\ndef unix_sockname(tmp_path, tmp_path_factory):\n    \"\"\"Generate an fs path to the UNIX domain socket for testing.\n\n    N.B. Different OS kernels have different fs path length limitations\n    for it. For Linux, it's 108, for HP-UX it's 92 (or higher) depending\n    on its version. For for most of the BSDs (Open, Free, macOS) it's\n    mostly 104 but sometimes it can be down to 100.\n\n    Ref: https://github.com/aio-libs/aiohttp/issues/3572\n    \"\"\"\n    if not hasattr(socket, \"AF_UNIX\"):\n        pytest.skip(\"requires UNIX sockets\")\n\n    max_sock_len = 92 if IS_HPUX else 108 if IS_LINUX else 100\n    \"\"\"Amount of bytes allocated for the UNIX socket path by OS kernel.\n\n    Ref: https://unix.stackexchange.com/a/367012/27133\n    \"\"\"\n\n    sock_file_name = \"unix.sock\"\n    unique_prefix = f\"{uuid4()!s}-\"\n    unique_prefix_len = len(unique_prefix.encode())\n\n    root_tmp_dir = Path(\"/tmp\").resolve()\n    os_tmp_dir = Path(os.getenv(\"TMPDIR\", \"/tmp\")).resolve()\n    original_base_tmp_path = Path(\n        str(tmp_path_factory.getbasetemp()),\n    ).resolve()\n\n    original_base_tmp_path_hash = md5(\n        str(original_base_tmp_path).encode(),\n    ).hexdigest()\n\n    def make_tmp_dir(base_tmp_dir):\n        return TemporaryDirectory(\n            dir=str(base_tmp_dir),\n            prefix=\"pt-\",\n            suffix=f\"-{original_base_tmp_path_hash!s}\",\n        )\n\n    def assert_sock_fits(sock_path):\n        sock_path_len = len(sock_path.encode())\n        # exit-check to verify that it's correct and simplify debugging\n        # in the future\n        assert sock_path_len <= max_sock_len, (\n            \"Suggested UNIX socket ({sock_path}) is {sock_path_len} bytes \"\n            \"long but the current kernel only has {max_sock_len} bytes \"\n            \"allocated to hold it so it must be shorter. \"\n            \"See https://github.com/aio-libs/aiohttp/issues/3572 \"\n            \"for more info.\"\n        ).format_map(locals())\n\n    paths = original_base_tmp_path, os_tmp_dir, root_tmp_dir\n    unique_paths = [p for n, p in enumerate(paths) if p not in paths[:n]]\n    paths_num = len(unique_paths)\n\n    for num, tmp_dir_path in enumerate(paths, 1):\n        with make_tmp_dir(tmp_dir_path) as tmpd:\n            tmpd = Path(tmpd).resolve()\n            sock_path = str(tmpd / sock_file_name)\n            sock_path_len = len(sock_path.encode())\n\n            if num >= paths_num:\n                # exit-check to verify that it's correct and simplify\n                # debugging in the future\n                assert_sock_fits(sock_path)\n\n            if sock_path_len <= max_sock_len:\n                if max_sock_len - sock_path_len >= unique_prefix_len:\n                    # If we're lucky to have extra space in the path,\n                    # let's also make it more unique\n                    sock_path = str(tmpd / \"\".join((unique_prefix, sock_file_name)))\n                    # Double-checking it:\n                    assert_sock_fits(sock_path)\n                yield sock_path\n                return\n\n\n@pytest.fixture\ndef pipe_name():\n    name = rf\"\\\\.\\pipe\\{uuid4().hex}\"\n    return name\n\n\n@pytest.fixture\ndef selector_loop():\n    policy = asyncio.WindowsSelectorEventLoopPolicy()\n    asyncio.set_event_loop_policy(policy)\n\n    with loop_context(policy.new_event_loop) as _loop:\n        asyncio.set_event_loop(_loop)\n        yield _loop\n\n\n@pytest.fixture\ndef netrc_contents(\n    tmp_path: Path,\n    monkeypatch: pytest.MonkeyPatch,\n    request: pytest.FixtureRequest,\n):\n    \"\"\"\n    Prepare :file:`.netrc` with given contents.\n\n    Monkey-patches :envvar:`NETRC` to point to created file.\n    \"\"\"\n    netrc_contents = getattr(request, \"param\", None)\n\n    netrc_file_path = tmp_path / \".netrc\"\n    if netrc_contents is not None:\n        netrc_file_path.write_text(netrc_contents)\n\n    monkeypatch.setenv(\"NETRC\", str(netrc_file_path))\n\n    return netrc_file_path\n"
    ],
    "test_file_names": [
        "test_1.py",
        "conftest.py"
    ],
    "setup_res_code": 0,
    "setup_res_stdout": "re-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/requirements/cython.txt\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/tools/gen.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/hdrs.py\n./tools/gen.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/_helpers.pyx\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/_http_parser.pyx\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/_http_writer.pyx\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/_websocket.pyx\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/_helpers.pyi\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/_cparser.pxd\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/_find_header.pxd\ncython -3 -o aiohttp/_helpers.c aiohttp/_helpers.pyx -I aiohttp\ncython -3 -o aiohttp/_http_parser.c aiohttp/_http_parser.pyx -I aiohttp\ncython -3 -o aiohttp/_http_writer.c aiohttp/_http_writer.pyx -I aiohttp\ncython -3 -o aiohttp/_websocket.c aiohttp/_websocket.pyx -I aiohttp\ncd vendor/llhttp; npm install\n\n> llhttp@9.0.0 prepare\n> npm run clean && npm run build-ts\n\n\n> llhttp@9.0.0 clean\n> rm -rf lib && rm -rf test/tmp\n\n\n> llhttp@9.0.0 build-ts\n> tsc\n\n\nadded 157 packages, and audited 158 packages in 4s\n\n23 packages are looking for funding\n  run `npm fund` for details\n\n5 vulnerabilities (4 moderate, 1 high)\n\nTo address issues that do not require attention, run:\n  npm audit fix\n\nSome issues need review, and may require choosing\na different dependency.\n\nRun `npm audit` for details.\nmake -C vendor/llhttp generate\nmake[1]: Entering directory '/home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/vendor/llhttp'\nnpx ts-node bin/generate.ts\nmake[1]: Leaving directory '/home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/vendor/llhttp'\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/__init__.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/abc.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/base_protocol.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/client.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/client_exceptions.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/client_proto.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/client_reqrep.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/client_ws.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/compression_utils.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/connector.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/cookiejar.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/formdata.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/helpers.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/http.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/http_exceptions.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/http_parser.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/http_websocket.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/http_writer.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/locks.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/log.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/multipart.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/payload.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/payload_streamer.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/pytest_plugin.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/resolver.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/streams.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/tcp_helpers.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/test_utils.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/tracing.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/typedefs.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/web.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/web_app.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/web_exceptions.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/web_fileresponse.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/web_log.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/web_middlewares.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/web_protocol.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/web_request.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/web_response.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/web_routedef.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/web_runner.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/web_server.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/web_urldispatcher.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/web_ws.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/aiohttp/worker.py\nuv pip install -e . -c requirements/runtime-deps.txt\n",
    "setup_res_stderr": "Using CPython 3.9.21\nCreating virtual environment at: .venv\nActivate with: source .venv/bin/activate\nResolved 1 package in 43ms\nPrepared 1 package in 0.30ms\nInstalled 1 package in 18ms\n + pip==24.3.1\nResolved 3 packages in 13ms\nInstalled 3 packages in 29ms\n + cython==3.0.0\n + multidict==6.0.4\n + typing-extensions==4.7.1\nwarning: aiohttp/_http_parser.pyx:51:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310\nwarning: aiohttp/_http_parser.pyx:84:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310\nwarning: aiohttp/_http_writer.pyx:10:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310\nResolved 96 packages in 46ms\nUninstalled 1 package in 4ms\nInstalled 94 packages in 180ms\n + aiodns==3.0.0\n + aiohttp-theme==0.1.6\n + aioredis==2.0.1\n + aiosignal==1.3.1\n + alabaster==0.7.13\n + async-timeout==4.0.3\n + attrs==23.1.0\n + babel==2.12.1\n + blockdiag==3.0.0\n + brotli==1.0.9\n + build==0.10.0\n + cchardet==2.1.7\n + certifi==2023.7.22\n + cffi==1.15.1\n + cfgv==3.3.1\n + charset-normalizer==3.2.0\n + cherry-picker==2.1.0\n + click==8.1.6\n + click-default-group==1.2.2\n + coverage==7.2.7\n + cryptography==41.0.3\n + distlib==0.3.7\n + docutils==0.20.1\n + exceptiongroup==1.1.2\n + filelock==3.12.2\n + freezegun==1.2.2\n + frozenlist==1.4.0\n + funcparserlib==1.0.1\n + gidgethub==5.3.0\n + gunicorn==21.2.0\n + identify==2.5.26\n + idna==3.4\n + imagesize==1.4.1\n + importlib-metadata==6.8.0\n + importlib-resources==6.0.0\n + incremental==22.10.0\n + iniconfig==2.0.0\n + jinja2==3.1.2\n + markupsafe==2.1.3\n + mypy==1.5.0\n + mypy-extensions==1.0.0\n + nodeenv==1.8.0\n + packaging==23.1\n + pillow==9.5.0\n - pip==24.3.1\n + pip==23.2.1\n + pip-tools==7.3.0\n + platformdirs==3.10.0\n + pluggy==1.2.0\n + pre-commit==3.3.3\n + proxy-py==2.4.3\n + pycares==4.3.0\n + pycparser==2.21\n + pydantic==1.10.2\n + pygments==2.15.1\n + pyjwt==2.8.0\n + pyproject-hooks==1.0.0\n + pytest==7.4.0\n + pytest-cov==4.1.0\n + pytest-mock==3.11.1\n + python-dateutil==2.8.2\n + python-on-whales==0.64.0\n + pyyaml==6.0.1\n + re-assert==1.1.0\n + regex==2023.6.3\n + requests==2.31.0\n + setuptools==68.0.0\n + setuptools-git==1.2\n + six==1.16.0\n + slotscheck==0.17.0\n + snowballstemmer==2.2.0\n + sphinx==7.1.2\n + sphinxcontrib-applehelp==1.0.4\n + sphinxcontrib-blockdiag==3.0.0\n + sphinxcontrib-devhelp==1.0.2\n + sphinxcontrib-htmlhelp==2.0.1\n + sphinxcontrib-jsmath==1.0.1\n + sphinxcontrib-qthelp==1.0.3\n + sphinxcontrib-serializinghtml==1.1.5\n + sphinxcontrib-towncrier==0.3.2a0\n + toml==0.10.2\n + tomli==2.0.1\n + towncrier==23.6.0\n + tqdm==4.65.0\n + trustme==1.1.0\n + typer==0.9.0\n + uritemplate==4.1.1\n + urllib3==2.0.4\n + uvloop==0.17.0\n + virtualenv==20.24.2\n + wait-for-it==2.2.2\n + webcolors==1.13\n + wheel==0.41.0\n + yarl==1.9.2\n + zipp==3.16.2\nResolved 9 packages in 1.74s\nPrepared 1 package in 16.42s\nInstalled 1 package in 0.65ms\n + aiohttp==3.9.0.dev0 (from file:///home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f)\nResolved 24 packages in 16ms\nInstalled 5 packages in 5ms\n + async-generator==1.10\n + brotlipy==0.7.0\n + chardet==5.2.0\n + multdict==0.0.5\n + pytest-asyncio==0.23.8\n",
    "new_commit_res_code": 0,
    "new_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.9.21, pytest-7.4.0, pluggy-1.2.0 -- /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/.venv/bin/python\ncachedir: .pytest_cache\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f\nconfigfile: setup.cfg\nplugins: mock-3.11.1, asyncio-0.23.8, cov-4.1.0\nasyncio: mode=strict\ncollecting ... collected 34 items\n\nr2e_tests/test_1.py::test_init_process[AsyncioWorker-pyloop] PASSED      [  2%]\nr2e_tests/test_1.py::test_init_process[UvloopWorker-pyloop] PASSED       [  5%]\nr2e_tests/test_1.py::test_run[AsyncioWorker-pyloop] PASSED               [  8%]\nr2e_tests/test_1.py::test_run[UvloopWorker-pyloop] PASSED                [ 11%]\nr2e_tests/test_1.py::test_run_async_factory[AsyncioWorker-pyloop] PASSED [ 14%]\nr2e_tests/test_1.py::test_run_async_factory[UvloopWorker-pyloop] PASSED  [ 17%]\nr2e_tests/test_1.py::test_run_not_app[AsyncioWorker-pyloop] PASSED       [ 20%]\nr2e_tests/test_1.py::test_run_not_app[UvloopWorker-pyloop] PASSED        [ 23%]\nr2e_tests/test_1.py::test_handle_abort[AsyncioWorker-pyloop] PASSED      [ 26%]\nr2e_tests/test_1.py::test_handle_abort[UvloopWorker-pyloop] PASSED       [ 29%]\nr2e_tests/test_1.py::test__wait_next_notify[AsyncioWorker-pyloop] PASSED [ 32%]\nr2e_tests/test_1.py::test__wait_next_notify[UvloopWorker-pyloop] PASSED  [ 35%]\nr2e_tests/test_1.py::test__notify_waiter_done[AsyncioWorker-pyloop] PASSED [ 38%]\nr2e_tests/test_1.py::test__notify_waiter_done[UvloopWorker-pyloop] PASSED [ 41%]\nr2e_tests/test_1.py::test__notify_waiter_done_explicit_waiter[AsyncioWorker-pyloop] PASSED [ 44%]\nr2e_tests/test_1.py::test__notify_waiter_done_explicit_waiter[UvloopWorker-pyloop] PASSED [ 47%]\nr2e_tests/test_1.py::test_init_signals[AsyncioWorker-pyloop] PASSED      [ 50%]\nr2e_tests/test_1.py::test_init_signals[UvloopWorker-pyloop] PASSED       [ 52%]\nr2e_tests/test_1.py::test__get_valid_log_format_ok[AsyncioWorker-pyloop-%a \"%{Referrer}i\" %s-%a \"%{Referrer}i\" %s] PASSED [ 55%]\nr2e_tests/test_1.py::test__get_valid_log_format_ok[AsyncioWorker-pyloop-%(h)s %(l)s %(u)s %(t)s \"%(r)s\" %(s)s %(b)s \"%(f)s\" \"%(a)s\"-%a %t \"%r\" %s %b \"%{Referer}i\" \"%{User-Agent}i\"] PASSED [ 58%]\nr2e_tests/test_1.py::test__get_valid_log_format_ok[UvloopWorker-pyloop-%a \"%{Referrer}i\" %s-%a \"%{Referrer}i\" %s] PASSED [ 61%]\nr2e_tests/test_1.py::test__get_valid_log_format_ok[UvloopWorker-pyloop-%(h)s %(l)s %(u)s %(t)s \"%(r)s\" %(s)s %(b)s \"%(f)s\" \"%(a)s\"-%a %t \"%r\" %s %b \"%{Referer}i\" \"%{User-Agent}i\"] PASSED [ 64%]\nr2e_tests/test_1.py::test__get_valid_log_format_exc[AsyncioWorker-pyloop] PASSED [ 67%]\nr2e_tests/test_1.py::test__get_valid_log_format_exc[UvloopWorker-pyloop] PASSED [ 70%]\nr2e_tests/test_1.py::test__run_ok_parent_changed[AsyncioWorker-pyloop] PASSED [ 73%]\nr2e_tests/test_1.py::test__run_ok_parent_changed[UvloopWorker-pyloop] PASSED [ 76%]\nr2e_tests/test_1.py::test__run_exc[AsyncioWorker-pyloop] PASSED          [ 79%]\nr2e_tests/test_1.py::test__run_exc[UvloopWorker-pyloop] PASSED           [ 82%]\nr2e_tests/test_1.py::test__create_ssl_context_without_certs_and_ciphers[AsyncioWorker-pyloop] PASSED [ 85%]\nr2e_tests/test_1.py::test__create_ssl_context_without_certs_and_ciphers[UvloopWorker-pyloop] PASSED [ 88%]\nr2e_tests/test_1.py::test__create_ssl_context_with_ciphers[AsyncioWorker-pyloop] PASSED [ 91%]\nr2e_tests/test_1.py::test__create_ssl_context_with_ciphers[UvloopWorker-pyloop] PASSED [ 94%]\nr2e_tests/test_1.py::test__create_ssl_context_with_ca_certs[AsyncioWorker-pyloop] PASSED [ 97%]\nr2e_tests/test_1.py::test__create_ssl_context_with_ca_certs[UvloopWorker-pyloop] PASSED [100%]\n\n==================================== PASSES ====================================\n\n---------- coverage: platform linux, python 3.9.21-final-0 -----------\nName                                     Stmts   Miss Branch BrPart  Cover\n--------------------------------------------------------------------------\naiohttp/__init__.py                         27     10      2      0    59%\naiohttp/abc.py                              90      6      0      0    93%\naiohttp/base_protocol.py                    66     51     22      0    17%\naiohttp/client.py                          488    367    178      2    19%\naiohttp/client_exceptions.py               135     61     16      0    49%\naiohttp/client_proto.py                    149    120     54      0    14%\naiohttp/client_reqrep.py                   649    488    280      0    18%\naiohttp/client_ws.py                       206    166     64      0    15%\naiohttp/compression_utils.py                65     34     14      0    39%\naiohttp/connector.py                       710    587    309      0    12%\naiohttp/cookiejar.py                       256    207    116      0    13%\naiohttp/formdata.py                         93     76     46      0    12%\naiohttp/hdrs.py                             90      0      0      0   100%\naiohttp/helpers.py                         511    320    176      5    31%\naiohttp/http.py                             11      0      2      0   100%\naiohttp/http_exceptions.py                  51     21      6      0    53%\naiohttp/http_parser.py                     476    382    176      1    15%\naiohttp/http_websocket.py                  385    285    152      0    19%\naiohttp/http_writer.py                     118     81     50      1    23%\naiohttp/locks.py                            24     16      4      0    29%\naiohttp/log.py                               7      0      0      0   100%\naiohttp/multipart.py                       562    455    232      0    14%\naiohttp/payload.py                         219    107     56      1    43%\naiohttp/payload_streamer.py                 29     10      4      0    70%\naiohttp/pytest_plugin.py                   167     82     42      6    48%\naiohttp/resolver.py                         68     48     22      0    22%\naiohttp/streams.py                         393    310    142      0    16%\naiohttp/tcp_helpers.py                      19     11      6      0    32%\naiohttp/test_utils.py                      322    192     54      2    36%\naiohttp/tracing.py                         191     69     32      0    69%\naiohttp/typedefs.py                         23      0      0      0   100%\naiohttp/web.py                             116     81     52      0    22%\naiohttp/web_app.py                         301    125     74     16    52%\naiohttp/web_exceptions.py                  151     22      6      0    82%\naiohttp/web_fileresponse.py                141    118     50      0    12%\naiohttp/web_log.py                         100     57     20      0    36%\naiohttp/web_middlewares.py                  55     37     20      0    24%\naiohttp/web_protocol.py                    343    283    157      0    12%\naiohttp/web_request.py                     435    285    128      1    28%\naiohttp/web_response.py                    474    361    206      0    17%\naiohttp/web_routedef.py                    106     46     10      0    55%\naiohttp/web_runner.py                      218     71     36     11    63%\naiohttp/web_server.py                       38     10      6      0    68%\naiohttp/web_urldispatcher.py               708    446    161      1    30%\naiohttp/web_ws.py                          316    254    106      0    15%\naiohttp/worker.py                          126      7     30      3    94%\ntests/__init__.py                            0      0      0      0   100%\ntests/conftest.py                          105    105     16      0     0%\ntests/test_base_protocol.py                198    198      2      0     0%\ntests/test_circular_imports.py              31     31     15      0     0%\ntests/test_classbasedview.py                39     39      0      0     0%\ntests/test_client_connection.py             94     94      2      0     0%\ntests/test_client_exceptions.py            183    183     14      0     0%\ntests/test_client_fingerprint.py            59     59      0      0     0%\ntests/test_client_functional.py           2188   2188     70      0     0%\ntests/test_client_proto.py                  99     99      0      0     0%\ntests/test_client_request.py               769    769     18      0     0%\ntests/test_client_response.py              469    469      2      0     0%\ntests/test_client_session.py               482    482     23      0     0%\ntests/test_client_ws.py                    415    415      2      0     0%\ntests/test_client_ws_functional.py         585    585     14      0     0%\ntests/test_connector.py                   1501   1501     76      0     0%\ntests/test_cookiejar.py                    332    332     22      0     0%\ntests/test_flowcontrol_streams.py          100    100      0      0     0%\ntests/test_formdata.py                      72     72      6      0     0%\ntests/test_helpers.py                      429    429     14      0     0%\ntests/test_http_exceptions.py              109    109     10      0     0%\ntests/test_http_parser.py                  785    785     40      0     0%\ntests/test_http_writer.py                  182    182     10      0     0%\ntests/test_imports.py                       31     31      6      0     0%\ntests/test_locks.py                         39     39      0      0     0%\ntests/test_loop.py                          36     36      0      0     0%\ntests/test_multipart.py                    747    747     22      0     0%\ntests/test_multipart_helpers.py            446    446      0      0     0%\ntests/test_payload.py                       94     94      0      0     0%\ntests/test_proxy.py                        245    245      0      0     0%\ntests/test_proxy_functional.py             472    472     22      0     0%\ntests/test_pytest_plugin.py                 27     27      0      0     0%\ntests/test_resolver.py                     176    176     12      0     0%\ntests/test_route_def.py                    210    210      0      0     0%\ntests/test_run_app.py                      460    460     24      0     0%\ntests/test_streams.py                     1071   1071     40      0     0%\ntests/test_tcp_helpers.py                   52     52      2      0     0%\ntests/test_test_utils.py                   242    242      6      0     0%\ntests/test_tracing.py                       48     48      0      0     0%\ntests/test_urldispatch.py                  844    844     24      0     0%\ntests/test_web_app.py                      454    454      6      0     0%\ntests/test_web_cli.py                       75     75      0      0     0%\ntests/test_web_exceptions.py               157    157     22      0     0%\ntests/test_web_functional.py              1520   1520     36      0     0%\ntests/test_web_log.py                      115    115      0      0     0%\ntests/test_web_middleware.py               266    266     12      0     0%\ntests/test_web_request.py                  490    490      8      0     0%\ntests/test_web_request_handler.py           40     40      0      0     0%\ntests/test_web_response.py                 817    817      4      0     0%\ntests/test_web_runner.py                   146    146      4      0     0%\ntests/test_web_sendfile.py                  76     76      0      0     0%\ntests/test_web_sendfile_functional.py      634    634     18      0     0%\ntests/test_web_server.py                   160    160      0      0     0%\ntests/test_web_urldispatcher.py            306    306     14      0     0%\ntests/test_web_websocket.py                304    304      4      0     0%\ntests/test_web_websocket_functional.py     542    542     16      0     0%\ntests/test_websocket_handshake.py          152    152     12      0     0%\ntests/test_websocket_parser.py             300    300     12      0     0%\ntests/test_websocket_writer.py              68     68      0      0     0%\ntests/test_worker.py                       191    191      4      0     0%\n--------------------------------------------------------------------------\nTOTAL                                    31507  28044   4005     50    10%\n\n============================= slowest 10 durations =============================\n0.10s call     r2e_tests/test_1.py::test__run_exc[UvloopWorker-pyloop]\n0.10s call     r2e_tests/test_1.py::test__run_exc[AsyncioWorker-pyloop]\n0.08s call     r2e_tests/test_1.py::test__wait_next_notify[AsyncioWorker-pyloop]\n0.07s call     r2e_tests/test_1.py::test__wait_next_notify[UvloopWorker-pyloop]\n0.07s setup    r2e_tests/test_1.py::test__create_ssl_context_without_certs_and_ciphers[AsyncioWorker-pyloop]\n0.03s teardown r2e_tests/test_1.py::test__wait_next_notify[UvloopWorker-pyloop]\n0.03s teardown r2e_tests/test_1.py::test__run_exc[UvloopWorker-pyloop]\n0.03s teardown r2e_tests/test_1.py::test_init_process[UvloopWorker-pyloop]\n0.03s teardown r2e_tests/test_1.py::test_init_process[AsyncioWorker-pyloop]\n0.03s teardown r2e_tests/test_1.py::test_run[AsyncioWorker-pyloop]\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::test_init_process[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test_init_process[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test_run[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test_run[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test_run_async_factory[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test_run_async_factory[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test_run_not_app[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test_run_not_app[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test_handle_abort[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test_handle_abort[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__wait_next_notify[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__wait_next_notify[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__notify_waiter_done[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__notify_waiter_done[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__notify_waiter_done_explicit_waiter[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__notify_waiter_done_explicit_waiter[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test_init_signals[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test_init_signals[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__get_valid_log_format_ok[AsyncioWorker-pyloop-%a \"%{Referrer}i\" %s-%a \"%{Referrer}i\" %s]\nPASSED r2e_tests/test_1.py::test__get_valid_log_format_ok[AsyncioWorker-pyloop-%(h)s %(l)s %(u)s %(t)s \"%(r)s\" %(s)s %(b)s \"%(f)s\" \"%(a)s\"-%a %t \"%r\" %s %b \"%{Referer}i\" \"%{User-Agent}i\"]\nPASSED r2e_tests/test_1.py::test__get_valid_log_format_ok[UvloopWorker-pyloop-%a \"%{Referrer}i\" %s-%a \"%{Referrer}i\" %s]\nPASSED r2e_tests/test_1.py::test__get_valid_log_format_ok[UvloopWorker-pyloop-%(h)s %(l)s %(u)s %(t)s \"%(r)s\" %(s)s %(b)s \"%(f)s\" \"%(a)s\"-%a %t \"%r\" %s %b \"%{Referer}i\" \"%{User-Agent}i\"]\nPASSED r2e_tests/test_1.py::test__get_valid_log_format_exc[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__get_valid_log_format_exc[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__run_ok_parent_changed[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__run_ok_parent_changed[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__run_exc[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__run_exc[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__create_ssl_context_without_certs_and_ciphers[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__create_ssl_context_without_certs_and_ciphers[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__create_ssl_context_with_ciphers[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__create_ssl_context_with_ciphers[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__create_ssl_context_with_ca_certs[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__create_ssl_context_with_ca_certs[UvloopWorker-pyloop]\n============================== 34 passed in 4.52s ==============================\n",
    "new_commit_res_stderr": "",
    "old_commit_res_code": 1,
    "old_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.9.21, pytest-7.4.0, pluggy-1.2.0 -- /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f/.venv/bin/python\ncachedir: .pytest_cache\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_800c7929cae8d9bb4605783a4d3b45ee9480840f\nconfigfile: setup.cfg\nplugins: mock-3.11.1, asyncio-0.23.8, cov-4.1.0\nasyncio: mode=strict\ncollecting ... collected 34 items\n\nr2e_tests/test_1.py::test_init_process[AsyncioWorker-pyloop] PASSED      [  2%]\nr2e_tests/test_1.py::test_init_process[UvloopWorker-pyloop] PASSED       [  5%]\nr2e_tests/test_1.py::test_run[AsyncioWorker-pyloop] PASSED               [  8%]\nr2e_tests/test_1.py::test_run[UvloopWorker-pyloop] PASSED                [ 11%]\nr2e_tests/test_1.py::test_run_async_factory[AsyncioWorker-pyloop] PASSED [ 14%]\nr2e_tests/test_1.py::test_run_async_factory[UvloopWorker-pyloop] PASSED  [ 17%]\nr2e_tests/test_1.py::test_run_not_app[AsyncioWorker-pyloop] PASSED       [ 20%]\nr2e_tests/test_1.py::test_run_not_app[UvloopWorker-pyloop] PASSED        [ 23%]\nr2e_tests/test_1.py::test_handle_abort[AsyncioWorker-pyloop] PASSED      [ 26%]\nr2e_tests/test_1.py::test_handle_abort[UvloopWorker-pyloop] PASSED       [ 29%]\nr2e_tests/test_1.py::test__wait_next_notify[AsyncioWorker-pyloop] PASSED [ 32%]\nr2e_tests/test_1.py::test__wait_next_notify[UvloopWorker-pyloop] PASSED  [ 35%]\nr2e_tests/test_1.py::test__notify_waiter_done[AsyncioWorker-pyloop] PASSED [ 38%]\nr2e_tests/test_1.py::test__notify_waiter_done[UvloopWorker-pyloop] PASSED [ 41%]\nr2e_tests/test_1.py::test__notify_waiter_done_explicit_waiter[AsyncioWorker-pyloop] PASSED [ 44%]\nr2e_tests/test_1.py::test__notify_waiter_done_explicit_waiter[UvloopWorker-pyloop] PASSED [ 47%]\nr2e_tests/test_1.py::test_init_signals[AsyncioWorker-pyloop] PASSED      [ 50%]\nr2e_tests/test_1.py::test_init_signals[UvloopWorker-pyloop] PASSED       [ 52%]\nr2e_tests/test_1.py::test__get_valid_log_format_ok[AsyncioWorker-pyloop-%a \"%{Referrer}i\" %s-%a \"%{Referrer}i\" %s] PASSED [ 55%]\nr2e_tests/test_1.py::test__get_valid_log_format_ok[AsyncioWorker-pyloop-%(h)s %(l)s %(u)s %(t)s \"%(r)s\" %(s)s %(b)s \"%(f)s\" \"%(a)s\"-%a %t \"%r\" %s %b \"%{Referer}i\" \"%{User-Agent}i\"] PASSED [ 58%]\nr2e_tests/test_1.py::test__get_valid_log_format_ok[UvloopWorker-pyloop-%a \"%{Referrer}i\" %s-%a \"%{Referrer}i\" %s] PASSED [ 61%]\nr2e_tests/test_1.py::test__get_valid_log_format_ok[UvloopWorker-pyloop-%(h)s %(l)s %(u)s %(t)s \"%(r)s\" %(s)s %(b)s \"%(f)s\" \"%(a)s\"-%a %t \"%r\" %s %b \"%{Referer}i\" \"%{User-Agent}i\"] PASSED [ 64%]\nr2e_tests/test_1.py::test__get_valid_log_format_exc[AsyncioWorker-pyloop] PASSED [ 67%]\nr2e_tests/test_1.py::test__get_valid_log_format_exc[UvloopWorker-pyloop] PASSED [ 70%]\nr2e_tests/test_1.py::test__run_ok_parent_changed[AsyncioWorker-pyloop] FAILED [ 73%]\nr2e_tests/test_1.py::test__run_ok_parent_changed[UvloopWorker-pyloop] FAILED [ 76%]\nr2e_tests/test_1.py::test__run_exc[AsyncioWorker-pyloop] PASSED          [ 79%]\nr2e_tests/test_1.py::test__run_exc[UvloopWorker-pyloop] PASSED           [ 82%]\nr2e_tests/test_1.py::test__create_ssl_context_without_certs_and_ciphers[AsyncioWorker-pyloop] PASSED [ 85%]\nr2e_tests/test_1.py::test__create_ssl_context_without_certs_and_ciphers[UvloopWorker-pyloop] PASSED [ 88%]\nr2e_tests/test_1.py::test__create_ssl_context_with_ciphers[AsyncioWorker-pyloop] PASSED [ 91%]\nr2e_tests/test_1.py::test__create_ssl_context_with_ciphers[UvloopWorker-pyloop] PASSED [ 94%]\nr2e_tests/test_1.py::test__create_ssl_context_with_ca_certs[AsyncioWorker-pyloop] PASSED [ 97%]\nr2e_tests/test_1.py::test__create_ssl_context_with_ca_certs[UvloopWorker-pyloop] PASSED [100%]\n\n=================================== FAILURES ===================================\n______________ test__run_ok_parent_changed[AsyncioWorker-pyloop] _______________\n\nself = <Mock name='mock.info' id='129802000925648'>\nargs = ('Parent changed, shutting down: %s', <r2e_tests.test_1.AsyncioWorker object at 0x760de228f820>)\nkwargs = {}\nexpected = \"info('Parent changed, shutting down: %s', <r2e_tests.test_1.AsyncioWorker object at 0x760de228f820>)\"\nactual = 'not called.'\nerror_message = \"expected call not found.\\nExpected: info('Parent changed, shutting down: %s', <r2e_tests.test_1.AsyncioWorker object at 0x760de228f820>)\\nActual: not called.\"\n\n    def assert_called_with(self, /, *args, **kwargs):\n        \"\"\"assert that the last call was made with the specified arguments.\n    \n        Raises an AssertionError if the args and keyword args passed in are\n        different to the last call to the mock.\"\"\"\n        if self.call_args is None:\n            expected = self._format_mock_call_signature(args, kwargs)\n            actual = 'not called.'\n            error_message = ('expected call not found.\\nExpected: %s\\nActual: %s'\n                    % (expected, actual))\n>           raise AssertionError(error_message)\nE           AssertionError: expected call not found.\nE           Expected: info('Parent changed, shutting down: %s', <r2e_tests.test_1.AsyncioWorker object at 0x760de228f820>)\nE           Actual: not called.\n\nactual     = 'not called.'\nargs       = ('Parent changed, shutting down: %s', <r2e_tests.test_1.AsyncioWorker object at 0x760de228f820>)\nerror_message = \"expected call not found.\\nExpected: info('Parent changed, shutting down: %s', <r2e_tests.test_1.AsyncioWorker object at 0x760de228f820>)\\nActual: not called.\"\nexpected   = \"info('Parent changed, shutting down: %s', <r2e_tests.test_1.AsyncioWorker object at 0x760de228f820>)\"\nkwargs     = {}\nself       = <Mock name='mock.info' id='129802000925648'>\n\n../../../../.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/mock.py:898: AssertionError\n\nDuring handling of the above exception, another exception occurred:\n\nworker = <r2e_tests.test_1.AsyncioWorker object at 0x760de228f820>\nloop = <_UnixSelectorEventLoop running=False closed=False debug=False>\naiohttp_unused_port = <function unused_port at 0x760de3421a60>\n\n    async def test__run_ok_parent_changed(\n        worker: base_worker.GunicornWebWorker,\n        loop: asyncio.AbstractEventLoop,\n        aiohttp_unused_port: Callable[[], int],\n    ) -> None:\n        worker.ppid = 0\n        worker.alive = True\n        sock = socket.socket()\n        addr = (\"localhost\", aiohttp_unused_port())\n        sock.bind(addr)\n        worker.sockets = [sock]\n        worker.log = mock.Mock()\n        worker.loop = loop\n        worker.max_requests = 0\n        worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT\n        worker.cfg.is_ssl = False\n    \n        await worker._run()\n    \n        worker.notify.assert_called_with()\n>       worker.log.info.assert_called_with(\"Parent changed, shutting down: %s\", worker)\nE       AssertionError: expected call not found.\nE       Expected: info('Parent changed, shutting down: %s', <r2e_tests.test_1.AsyncioWorker object at 0x760de228f820>)\nE       Actual: not called.\n\naddr       = ('localhost', 40997)\naiohttp_unused_port = <function unused_port at 0x760de3421a60>\nloop       = <_UnixSelectorEventLoop running=False closed=False debug=False>\nsock       = <socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>\nworker     = <r2e_tests.test_1.AsyncioWorker object at 0x760de228f820>\n\nr2e_tests/test_1.py:227: AssertionError\n_______________ test__run_ok_parent_changed[UvloopWorker-pyloop] _______________\n\nself = <Mock name='mock.info' id='129802002410272'>\nargs = ('Parent changed, shutting down: %s', <r2e_tests.test_1.UvloopWorker object at 0x760de2280c70>)\nkwargs = {}\nexpected = \"info('Parent changed, shutting down: %s', <r2e_tests.test_1.UvloopWorker object at 0x760de2280c70>)\"\nactual = 'not called.'\nerror_message = \"expected call not found.\\nExpected: info('Parent changed, shutting down: %s', <r2e_tests.test_1.UvloopWorker object at 0x760de2280c70>)\\nActual: not called.\"\n\n    def assert_called_with(self, /, *args, **kwargs):\n        \"\"\"assert that the last call was made with the specified arguments.\n    \n        Raises an AssertionError if the args and keyword args passed in are\n        different to the last call to the mock.\"\"\"\n        if self.call_args is None:\n            expected = self._format_mock_call_signature(args, kwargs)\n            actual = 'not called.'\n            error_message = ('expected call not found.\\nExpected: %s\\nActual: %s'\n                    % (expected, actual))\n>           raise AssertionError(error_message)\nE           AssertionError: expected call not found.\nE           Expected: info('Parent changed, shutting down: %s', <r2e_tests.test_1.UvloopWorker object at 0x760de2280c70>)\nE           Actual: not called.\n\nactual     = 'not called.'\nargs       = ('Parent changed, shutting down: %s', <r2e_tests.test_1.UvloopWorker object at 0x760de2280c70>)\nerror_message = \"expected call not found.\\nExpected: info('Parent changed, shutting down: %s', <r2e_tests.test_1.UvloopWorker object at 0x760de2280c70>)\\nActual: not called.\"\nexpected   = \"info('Parent changed, shutting down: %s', <r2e_tests.test_1.UvloopWorker object at 0x760de2280c70>)\"\nkwargs     = {}\nself       = <Mock name='mock.info' id='129802002410272'>\n\n../../../../.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/mock.py:898: AssertionError\n\nDuring handling of the above exception, another exception occurred:\n\nworker = <r2e_tests.test_1.UvloopWorker object at 0x760de2280c70>\nloop = <_UnixSelectorEventLoop running=False closed=False debug=False>\naiohttp_unused_port = <function unused_port at 0x760de3421a60>\n\n    async def test__run_ok_parent_changed(\n        worker: base_worker.GunicornWebWorker,\n        loop: asyncio.AbstractEventLoop,\n        aiohttp_unused_port: Callable[[], int],\n    ) -> None:\n        worker.ppid = 0\n        worker.alive = True\n        sock = socket.socket()\n        addr = (\"localhost\", aiohttp_unused_port())\n        sock.bind(addr)\n        worker.sockets = [sock]\n        worker.log = mock.Mock()\n        worker.loop = loop\n        worker.max_requests = 0\n        worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT\n        worker.cfg.is_ssl = False\n    \n        await worker._run()\n    \n        worker.notify.assert_called_with()\n>       worker.log.info.assert_called_with(\"Parent changed, shutting down: %s\", worker)\nE       AssertionError: expected call not found.\nE       Expected: info('Parent changed, shutting down: %s', <r2e_tests.test_1.UvloopWorker object at 0x760de2280c70>)\nE       Actual: not called.\n\naddr       = ('localhost', 57675)\naiohttp_unused_port = <function unused_port at 0x760de3421a60>\nloop       = <_UnixSelectorEventLoop running=False closed=False debug=False>\nsock       = <socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>\nworker     = <r2e_tests.test_1.UvloopWorker object at 0x760de2280c70>\n\nr2e_tests/test_1.py:227: AssertionError\n==================================== PASSES ====================================\n\n---------- coverage: platform linux, python 3.9.21-final-0 -----------\nName                                     Stmts   Miss Branch BrPart  Cover\n--------------------------------------------------------------------------\naiohttp/__init__.py                         27     10      2      0    59%\naiohttp/abc.py                              90      6      0      0    93%\naiohttp/base_protocol.py                    66     51     22      0    17%\naiohttp/client.py                          488    367    178      2    19%\naiohttp/client_exceptions.py               135     61     16      0    49%\naiohttp/client_proto.py                    149    120     54      0    14%\naiohttp/client_reqrep.py                   649    488    280      0    18%\naiohttp/client_ws.py                       206    166     64      0    15%\naiohttp/compression_utils.py                65     34     14      0    39%\naiohttp/connector.py                       710    587    309      0    12%\naiohttp/cookiejar.py                       256    207    116      0    13%\naiohttp/formdata.py                         93     76     46      0    12%\naiohttp/hdrs.py                             90      0      0      0   100%\naiohttp/helpers.py                         511    320    176      5    31%\naiohttp/http.py                             11      0      2      0   100%\naiohttp/http_exceptions.py                  51     21      6      0    53%\naiohttp/http_parser.py                     476    382    176      1    15%\naiohttp/http_websocket.py                  385    285    152      0    19%\naiohttp/http_writer.py                     118     81     50      1    23%\naiohttp/locks.py                            24     16      4      0    29%\naiohttp/log.py                               7      0      0      0   100%\naiohttp/multipart.py                       562    455    232      0    14%\naiohttp/payload.py                         219    107     56      1    43%\naiohttp/payload_streamer.py                 29     10      4      0    70%\naiohttp/pytest_plugin.py                   167     81     42      6    49%\naiohttp/resolver.py                         68     48     22      0    22%\naiohttp/streams.py                         393    310    142      0    16%\naiohttp/tcp_helpers.py                      19     11      6      0    32%\naiohttp/test_utils.py                      322    192     54      2    36%\naiohttp/tracing.py                         191     69     32      0    69%\naiohttp/typedefs.py                         23      0      0      0   100%\naiohttp/web.py                             116     81     52      0    22%\naiohttp/web_app.py                         301    125     74     16    52%\naiohttp/web_exceptions.py                  151     22      6      0    82%\naiohttp/web_fileresponse.py                141    118     50      0    12%\naiohttp/web_log.py                         100     57     20      0    36%\naiohttp/web_middlewares.py                  55     37     20      0    24%\naiohttp/web_protocol.py                    343    283    157      0    12%\naiohttp/web_request.py                     435    285    128      1    28%\naiohttp/web_response.py                    474    361    206      0    17%\naiohttp/web_routedef.py                    106     46     10      0    55%\naiohttp/web_runner.py                      218     71     36     11    63%\naiohttp/web_server.py                       38     10      6      0    68%\naiohttp/web_urldispatcher.py               708    446    161      1    30%\naiohttp/web_ws.py                          316    254    106      0    15%\naiohttp/worker.py                          126     11     30      4    89%\ntests/__init__.py                            0      0      0      0   100%\ntests/conftest.py                          105    105     16      0     0%\ntests/test_base_protocol.py                198    198      2      0     0%\ntests/test_circular_imports.py              31     31     15      0     0%\ntests/test_classbasedview.py                39     39      0      0     0%\ntests/test_client_connection.py             94     94      2      0     0%\ntests/test_client_exceptions.py            183    183     14      0     0%\ntests/test_client_fingerprint.py            59     59      0      0     0%\ntests/test_client_functional.py           2188   2188     70      0     0%\ntests/test_client_proto.py                  99     99      0      0     0%\ntests/test_client_request.py               769    769     18      0     0%\ntests/test_client_response.py              469    469      2      0     0%\ntests/test_client_session.py               482    482     23      0     0%\ntests/test_client_ws.py                    415    415      2      0     0%\ntests/test_client_ws_functional.py         585    585     14      0     0%\ntests/test_connector.py                   1501   1501     76      0     0%\ntests/test_cookiejar.py                    332    332     22      0     0%\ntests/test_flowcontrol_streams.py          100    100      0      0     0%\ntests/test_formdata.py                      72     72      6      0     0%\ntests/test_helpers.py                      429    429     14      0     0%\ntests/test_http_exceptions.py              109    109     10      0     0%\ntests/test_http_parser.py                  785    785     40      0     0%\ntests/test_http_writer.py                  182    182     10      0     0%\ntests/test_imports.py                       31     31      6      0     0%\ntests/test_locks.py                         39     39      0      0     0%\ntests/test_loop.py                          36     36      0      0     0%\ntests/test_multipart.py                    747    747     22      0     0%\ntests/test_multipart_helpers.py            446    446      0      0     0%\ntests/test_payload.py                       94     94      0      0     0%\ntests/test_proxy.py                        245    245      0      0     0%\ntests/test_proxy_functional.py             472    472     22      0     0%\ntests/test_pytest_plugin.py                 27     27      0      0     0%\ntests/test_resolver.py                     176    176     12      0     0%\ntests/test_route_def.py                    210    210      0      0     0%\ntests/test_run_app.py                      460    460     24      0     0%\ntests/test_streams.py                     1071   1071     40      0     0%\ntests/test_tcp_helpers.py                   52     52      2      0     0%\ntests/test_test_utils.py                   242    242      6      0     0%\ntests/test_tracing.py                       48     48      0      0     0%\ntests/test_urldispatch.py                  844    844     24      0     0%\ntests/test_web_app.py                      454    454      6      0     0%\ntests/test_web_cli.py                       75     75      0      0     0%\ntests/test_web_exceptions.py               157    157     22      0     0%\ntests/test_web_functional.py              1520   1520     36      0     0%\ntests/test_web_log.py                      115    115      0      0     0%\ntests/test_web_middleware.py               266    266     12      0     0%\ntests/test_web_request.py                  490    490      8      0     0%\ntests/test_web_request_handler.py           40     40      0      0     0%\ntests/test_web_response.py                 817    817      4      0     0%\ntests/test_web_runner.py                   146    146      4      0     0%\ntests/test_web_sendfile.py                  76     76      0      0     0%\ntests/test_web_sendfile_functional.py      634    634     18      0     0%\ntests/test_web_server.py                   160    160      0      0     0%\ntests/test_web_urldispatcher.py            306    306     14      0     0%\ntests/test_web_websocket.py                304    304      4      0     0%\ntests/test_web_websocket_functional.py     542    542     16      0     0%\ntests/test_websocket_handshake.py          152    152     12      0     0%\ntests/test_websocket_parser.py             300    300     12      0     0%\ntests/test_websocket_writer.py              68     68      0      0     0%\ntests/test_worker.py                       191    191      4      0     0%\n--------------------------------------------------------------------------\nTOTAL                                    31507  28047   4005     51    10%\n\n============================= slowest 10 durations =============================\n0.08s call     r2e_tests/test_1.py::test__wait_next_notify[AsyncioWorker-pyloop]\n0.07s call     r2e_tests/test_1.py::test__wait_next_notify[UvloopWorker-pyloop]\n0.03s teardown r2e_tests/test_1.py::test__wait_next_notify[UvloopWorker-pyloop]\n0.02s teardown r2e_tests/test_1.py::test__run_ok_parent_changed[AsyncioWorker-pyloop]\n0.02s teardown r2e_tests/test_1.py::test__wait_next_notify[AsyncioWorker-pyloop]\n0.02s teardown r2e_tests/test_1.py::test__run_ok_parent_changed[UvloopWorker-pyloop]\n0.02s teardown r2e_tests/test_1.py::test__create_ssl_context_without_certs_and_ciphers[AsyncioWorker-pyloop]\n0.02s teardown r2e_tests/test_1.py::test__create_ssl_context_with_ciphers[UvloopWorker-pyloop]\n0.02s teardown r2e_tests/test_1.py::test__create_ssl_context_without_certs_and_ciphers[UvloopWorker-pyloop]\n0.02s teardown r2e_tests/test_1.py::test__notify_waiter_done[AsyncioWorker-pyloop]\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::test_init_process[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test_init_process[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test_run[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test_run[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test_run_async_factory[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test_run_async_factory[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test_run_not_app[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test_run_not_app[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test_handle_abort[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test_handle_abort[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__wait_next_notify[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__wait_next_notify[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__notify_waiter_done[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__notify_waiter_done[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__notify_waiter_done_explicit_waiter[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__notify_waiter_done_explicit_waiter[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test_init_signals[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test_init_signals[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__get_valid_log_format_ok[AsyncioWorker-pyloop-%a \"%{Referrer}i\" %s-%a \"%{Referrer}i\" %s]\nPASSED r2e_tests/test_1.py::test__get_valid_log_format_ok[AsyncioWorker-pyloop-%(h)s %(l)s %(u)s %(t)s \"%(r)s\" %(s)s %(b)s \"%(f)s\" \"%(a)s\"-%a %t \"%r\" %s %b \"%{Referer}i\" \"%{User-Agent}i\"]\nPASSED r2e_tests/test_1.py::test__get_valid_log_format_ok[UvloopWorker-pyloop-%a \"%{Referrer}i\" %s-%a \"%{Referrer}i\" %s]\nPASSED r2e_tests/test_1.py::test__get_valid_log_format_ok[UvloopWorker-pyloop-%(h)s %(l)s %(u)s %(t)s \"%(r)s\" %(s)s %(b)s \"%(f)s\" \"%(a)s\"-%a %t \"%r\" %s %b \"%{Referer}i\" \"%{User-Agent}i\"]\nPASSED r2e_tests/test_1.py::test__get_valid_log_format_exc[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__get_valid_log_format_exc[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__run_exc[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__run_exc[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__create_ssl_context_without_certs_and_ciphers[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__create_ssl_context_without_certs_and_ciphers[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__create_ssl_context_with_ciphers[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__create_ssl_context_with_ciphers[UvloopWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__create_ssl_context_with_ca_certs[AsyncioWorker-pyloop]\nPASSED r2e_tests/test_1.py::test__create_ssl_context_with_ca_certs[UvloopWorker-pyloop]\nFAILED r2e_tests/test_1.py::test__run_ok_parent_changed[AsyncioWorker-pyloop]\nFAILED r2e_tests/test_1.py::test__run_ok_parent_changed[UvloopWorker-pyloop]\n========================= 2 failed, 32 passed in 4.17s =========================\n",
    "old_commit_res_stderr": ""
}
CHANGES/7518.bugfix aiohttp/worker.py tests/test_worker.py
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]
**Title:** `max_requests_jitter` Parameter in `GunicornWebWorker` Not Taking Effect

**Description**

When configuring the `GunicornWebWorker` with the `max_requests_jitter` parameter, the jitter is not applied correctly. This results in the worker not shutting down as expected after reaching the maximum number of requests, which can lead to unintended prolonged runtimes.

**Example Code**

```python
worker.max_requests = 0
worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT
worker.cfg.is_ssl = False

await worker._run()

# Expected: The worker should log "Parent changed, shutting down: <Worker>" and terminate.
# Actual: The log message is not called, and the worker does not shut down.
```

**Expected Behavior**

When `max_requests_jitter` is set, the `GunicornWebWorker` should apply the jitter to the `max_requests` limit. Upon reaching the adjusted request count, the worker should log an informational message indicating it is shutting down and then terminate gracefully.

**Actual Behavior**

The `max_requests_jitter` parameter does not influence the worker's behavior because the worker incorrectly references `self.cfg.max_requests` instead of `self.max_requests`. Consequently, the worker does not log the shutdown message and remains active beyond the intended request limit.
[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### aiohttp/worker.py
"""Async gunicorn worker for aiohttp.web"""

import asyncio
import os
import re
import signal
import sys
from types import FrameType
from typing import Any, Awaitable, Callable, Optional, Union  # noqa

from gunicorn.config import AccessLogFormat as GunicornAccessLogFormat
from gunicorn.workers import base

from aiohttp import web

from .helpers import set_result
from .web_app import Application
from .web_log import AccessLogger

try:
    import ssl

    SSLContext = ssl.SSLContext
except ImportError:  # pragma: no cover
    ssl = None  # type: ignore[assignment]
    SSLContext = object  # type: ignore[misc,assignment]


__all__ = ("GunicornWebWorker", "GunicornUVLoopWebWorker")


class GunicornWebWorker(base.Worker):  # type: ignore[misc,no-any-unimported]

    DEFAULT_AIOHTTP_LOG_FORMAT = AccessLogger.LOG_FORMAT
    DEFAULT_GUNICORN_LOG_FORMAT = GunicornAccessLogFormat.default

    def __init__(self, *args: Any, **kw: Any) -> None:  # pragma: no cover
        super().__init__(*args, **kw)

        self._task: Optional[asyncio.Task[None]] = None
        self.exit_code = 0
        self._notify_waiter: Optional[asyncio.Future[bool]] = None

    def init_process(self) -> None:
        # create new event_loop after fork
        asyncio.get_event_loop().close()

        self.loop = asyncio.new_event_loop()
        asyncio.set_event_loop(self.loop)

        super().init_process()

    def run(self) -> None:
        self._task = self.loop.create_task(self._run())

        try:  # ignore all finalization problems
            self.loop.run_until_complete(self._task)
        except Exception:
            self.log.exception("Exception in gunicorn worker")
        self.loop.run_until_complete(self.loop.shutdown_asyncgens())
        self.loop.close()

        sys.exit(self.exit_code)

    async def _run(self) -> None:
        runner = None
        if isinstance(self.wsgi, Application):
            app = self.wsgi
        elif asyncio.iscoroutinefunction(self.wsgi):
            wsgi = await self.wsgi()
            if isinstance(wsgi, web.AppRunner):
                runner = wsgi
                app = runner.app
            else:
                app = wsgi
        else:
            raise RuntimeError(
                "wsgi app should be either Application or "
                "async function returning Application, got {}".format(self.wsgi)
            )

        if runner is None:
            access_log = self.log.access_log if self.cfg.accesslog else None
            runner = web.AppRunner(
                app,
                logger=self.log,
                keepalive_timeout=self.cfg.keepalive,
                access_log=access_log,
                access_log_format=self._get_valid_log_format(
                    self.cfg.access_log_format
                ),
            )
        await runner.setup()

        ctx = self._create_ssl_context(self.cfg) if self.cfg.is_ssl else None

        runner = runner
        assert runner is not None
        server = runner.server
        assert server is not None
        for sock in self.sockets:
            site = web.SockSite(
                runner,
                sock,
                ssl_context=ctx,
                shutdown_timeout=self.cfg.graceful_timeout / 100 * 95,
            )
            await site.start()

        # If our parent changed then we shut down.
        pid = os.getpid()
        try:
            while self.alive:  # type: ignore[has-type]
                self.notify()

                cnt = server.requests_count
                if self.cfg.max_requests and cnt > self.cfg.max_requests:
                    self.alive = False
                    self.log.info("Max requests, shutting down: %s", self)

                elif pid == os.getpid() and self.ppid != os.getppid():
                    self.alive = False
                    self.log.info("Parent changed, shutting down: %s", self)
                else:
                    await self._wait_next_notify()
        except BaseException:
            pass

        await runner.cleanup()

    def _wait_next_notify(self) -> "asyncio.Future[bool]":
        self._notify_waiter_done()

        loop = self.loop
        assert loop is not None
        self._notify_waiter = waiter = loop.create_future()
        self.loop.call_later(1.0, self._notify_waiter_done, waiter)

        return waiter

    def _notify_waiter_done(
        self, waiter: Optional["asyncio.Future[bool]"] = None
    ) -> None:
        if waiter is None:
            waiter = self._notify_waiter
        if waiter is not None:
            set_result(waiter, True)

        if waiter is self._notify_waiter:
            self._notify_waiter = None

    def init_signals(self) -> None:
        # Set up signals through the event loop API.

        self.loop.add_signal_handler(
            signal.SIGQUIT, self.handle_quit, signal.SIGQUIT, None
        )

        self.loop.add_signal_handler(
            signal.SIGTERM, self.handle_exit, signal.SIGTERM, None
        )

        self.loop.add_signal_handler(
            signal.SIGINT, self.handle_quit, signal.SIGINT, None
        )

        self.loop.add_signal_handler(
            signal.SIGWINCH, self.handle_winch, signal.SIGWINCH, None
        )

        self.loop.add_signal_handler(
            signal.SIGUSR1, self.handle_usr1, signal.SIGUSR1, None
        )

        self.loop.add_signal_handler(
            signal.SIGABRT, self.handle_abort, signal.SIGABRT, None
        )

        # Don't let SIGTERM and SIGUSR1 disturb active requests
        # by interrupting system calls
        signal.siginterrupt(signal.SIGTERM, False)
        signal.siginterrupt(signal.SIGUSR1, False)
        # Reset signals so Gunicorn doesn't swallow subprocess return codes
        # See: https://github.com/aio-libs/aiohttp/issues/6130

    def handle_quit(self, sig: int, frame: Optional[FrameType]) -> None:
        self.alive = False

        # worker_int callback
        self.cfg.worker_int(self)

        # wakeup closing process
        self._notify_waiter_done()

    def handle_abort(self, sig: int, frame: Optional[FrameType]) -> None:
        self.alive = False
        self.exit_code = 1
        self.cfg.worker_abort(self)
        sys.exit(1)

    @staticmethod
    def _create_ssl_context(cfg: Any) -> "SSLContext":
        """Creates SSLContext instance for usage in asyncio.create_server.

        See ssl.SSLSocket.__init__ for more details.
        """
        if ssl is None:  # pragma: no cover
            raise RuntimeError("SSL is not supported.")

        ctx = ssl.SSLContext(cfg.ssl_version)
        ctx.load_cert_chain(cfg.certfile, cfg.keyfile)
        ctx.verify_mode = cfg.cert_reqs
        if cfg.ca_certs:
            ctx.load_verify_locations(cfg.ca_certs)
        if cfg.ciphers:
            ctx.set_ciphers(cfg.ciphers)
        return ctx

    def _get_valid_log_format(self, source_format: str) -> str:
        if source_format == self.DEFAULT_GUNICORN_LOG_FORMAT:
            return self.DEFAULT_AIOHTTP_LOG_FORMAT
        elif re.search(r"%\([^\)]+\)", source_format):
            raise ValueError(
                "Gunicorn's style options in form of `%(name)s` are not "
                "supported for the log formatting. Please use aiohttp's "
                "format specification to configure access log formatting: "
                "http://docs.aiohttp.org/en/stable/logging.html"
                "#format-specification"
            )
        else:
            return source_format


class GunicornUVLoopWebWorker(GunicornWebWorker):
    def init_process(self) -> None:
        import uvloop

        # Close any existing event loop before setting a
        # new policy.
        asyncio.get_event_loop().close()

        # Setup uvloop policy, so that every
        # asyncio.get_event_loop() will create an instance
        # of uvloop event loop.
        asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())

        super().init_process()

```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
[ISSUE]
**Title:** `max_requests_jitter` Parameter in `GunicornWebWorker` Not Taking Effect

**Description**

When configuring the `GunicornWebWorker` with the `max_requests_jitter` parameter, the jitter is not applied correctly. This results in the worker not shutting down as expected after reaching the maximum number of requests, which can lead to unintended prolonged runtimes.

**Example Code**

```python
worker.max_requests = 0
worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT
worker.cfg.is_ssl = False

await worker._run()

# Expected: The worker should log "Parent changed, shutting down: <Worker>" and terminate.
# Actual: The log message is not called, and the worker does not shut down.
```

**Expected Behavior**

When `max_requests_jitter` is set, the `GunicornWebWorker` should apply the jitter to the `max_requests` limit. Upon reaching the adjusted request count, the worker should log an informational message indicating it is shutting down and then terminate gracefully.

**Actual Behavior**

The `max_requests_jitter` parameter does not influence the worker's behavior because the worker incorrectly references `self.cfg.max_requests` instead of `self.max_requests`. Consequently, the worker does not log the shutdown message and remains active beyond the intended request limit.
[/ISSUE]
{
    "test_init_process[AsyncioWorker-pyloop]": "PASSED",
    "test_init_process[UvloopWorker-pyloop]": "PASSED",
    "test_run[AsyncioWorker-pyloop]": "PASSED",
    "test_run[UvloopWorker-pyloop]": "PASSED",
    "test_run_async_factory[AsyncioWorker-pyloop]": "PASSED",
    "test_run_async_factory[UvloopWorker-pyloop]": "PASSED",
    "test_run_not_app[AsyncioWorker-pyloop]": "PASSED",
    "test_run_not_app[UvloopWorker-pyloop]": "PASSED",
    "test_handle_abort[AsyncioWorker-pyloop]": "PASSED",
    "test_handle_abort[UvloopWorker-pyloop]": "PASSED",
    "test__wait_next_notify[AsyncioWorker-pyloop]": "PASSED",
    "test__wait_next_notify[UvloopWorker-pyloop]": "PASSED",
    "test__notify_waiter_done[AsyncioWorker-pyloop]": "PASSED",
    "test__notify_waiter_done[UvloopWorker-pyloop]": "PASSED",
    "test__notify_waiter_done_explicit_waiter[AsyncioWorker-pyloop]": "PASSED",
    "test__notify_waiter_done_explicit_waiter[UvloopWorker-pyloop]": "PASSED",
    "test_init_signals[AsyncioWorker-pyloop]": "PASSED",
    "test_init_signals[UvloopWorker-pyloop]": "PASSED",
    "test__get_valid_log_format_ok[AsyncioWorker-pyloop-%a \"%{Referrer}i\" %s-%a \"%{Referrer}i\" %s]": "PASSED",
    "test__get_valid_log_format_ok[AsyncioWorker-pyloop-%(h)s %(l)s %(u)s %(t)s \"%(r)s\" %(s)s %(b)s \"%(f)s\" \"%(a)s\"-%a %t \"%r\" %s %b \"%{Referer}i\" \"%{User-Agent}i\"]": "PASSED",
    "test__get_valid_log_format_ok[UvloopWorker-pyloop-%a \"%{Referrer}i\" %s-%a \"%{Referrer}i\" %s]": "PASSED",
    "test__get_valid_log_format_ok[UvloopWorker-pyloop-%(h)s %(l)s %(u)s %(t)s \"%(r)s\" %(s)s %(b)s \"%(f)s\" \"%(a)s\"-%a %t \"%r\" %s %b \"%{Referer}i\" \"%{User-Agent}i\"]": "PASSED",
    "test__get_valid_log_format_exc[AsyncioWorker-pyloop]": "PASSED",
    "test__get_valid_log_format_exc[UvloopWorker-pyloop]": "PASSED",
    "test__run_ok_parent_changed[AsyncioWorker-pyloop]": "PASSED",
    "test__run_ok_parent_changed[UvloopWorker-pyloop]": "PASSED",
    "test__run_exc[AsyncioWorker-pyloop]": "PASSED",
    "test__run_exc[UvloopWorker-pyloop]": "PASSED",
    "test__create_ssl_context_without_certs_and_ciphers[AsyncioWorker-pyloop]": "PASSED",
    "test__create_ssl_context_without_certs_and_ciphers[UvloopWorker-pyloop]": "PASSED",
    "test__create_ssl_context_with_ciphers[AsyncioWorker-pyloop]": "PASSED",
    "test__create_ssl_context_with_ciphers[UvloopWorker-pyloop]": "PASSED",
    "test__create_ssl_context_with_ca_certs[AsyncioWorker-pyloop]": "PASSED",
    "test__create_ssl_context_with_ca_certs[UvloopWorker-pyloop]": "PASSED"
}
diff --git a/aiohttp/worker.py b/aiohttp/worker.py
index 975046e6..04822f33 100644
--- a/aiohttp/worker.py
+++ b/aiohttp/worker.py
@@ -114,7 +114,7 @@ class GunicornWebWorker(base.Worker):  # type: ignore[misc,no-any-unimported]
                 self.notify()
 
                 cnt = server.requests_count
-                if self.cfg.max_requests and cnt > self.cfg.max_requests:
+                if self.max_requests and cnt > self.max_requests:
                     self.alive = False
                     self.log.info("Max requests, shutting down: %s", self)
 

{"aiohttp/worker.py": "\"\"\"Async gunicorn worker for aiohttp.web\"\"\"\n\nimport asyncio\nimport os\nimport re\nimport signal\nimport sys\nfrom types import FrameType\nfrom typing import Any, Awaitable, Callable, Optional, Union  # noqa\n\nfrom gunicorn.config import AccessLogFormat as GunicornAccessLogFormat\nfrom gunicorn.workers import base\n\nfrom aiohttp import web\n\nfrom .helpers import set_result\nfrom .web_app import Application\nfrom .web_log import AccessLogger\n\ntry:\n    import ssl\n\n    SSLContext = ssl.SSLContext\nexcept ImportError:  # pragma: no cover\n    ssl = None  # type: ignore[assignment]\n    SSLContext = object  # type: ignore[misc,assignment]\n\n\n__all__ = (\"GunicornWebWorker\", \"GunicornUVLoopWebWorker\")\n\n\nclass GunicornWebWorker(base.Worker):  # type: ignore[misc,no-any-unimported]\n\n    DEFAULT_AIOHTTP_LOG_FORMAT = AccessLogger.LOG_FORMAT\n    DEFAULT_GUNICORN_LOG_FORMAT = GunicornAccessLogFormat.default\n\n    def __init__(self, *args: Any, **kw: Any) -> None:  # pragma: no cover\n        super().__init__(*args, **kw)\n\n        self._task: Optional[asyncio.Task[None]] = None\n        self.exit_code = 0\n        self._notify_waiter: Optional[asyncio.Future[bool]] = None\n\n    def init_process(self) -> None:\n        # create new event_loop after fork\n        asyncio.get_event_loop().close()\n\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(self.loop)\n\n        super().init_process()\n\n    def run(self) -> None:\n        self._task = self.loop.create_task(self._run())\n\n        try:  # ignore all finalization problems\n            self.loop.run_until_complete(self._task)\n        except Exception:\n            self.log.exception(\"Exception in gunicorn worker\")\n        self.loop.run_until_complete(self.loop.shutdown_asyncgens())\n        self.loop.close()\n\n        sys.exit(self.exit_code)\n\n    async def _run(self) -> None:\n        runner = None\n        if isinstance(self.wsgi, Application):\n            app = self.wsgi\n        elif asyncio.iscoroutinefunction(self.wsgi):\n            wsgi = await self.wsgi()\n            if isinstance(wsgi, web.AppRunner):\n                runner = wsgi\n                app = runner.app\n            else:\n                app = wsgi\n        else:\n            raise RuntimeError(\n                \"wsgi app should be either Application or \"\n                \"async function returning Application, got {}\".format(self.wsgi)\n            )\n\n        if runner is None:\n            access_log = self.log.access_log if self.cfg.accesslog else None\n            runner = web.AppRunner(\n                app,\n                logger=self.log,\n                keepalive_timeout=self.cfg.keepalive,\n                access_log=access_log,\n                access_log_format=self._get_valid_log_format(\n                    self.cfg.access_log_format\n                ),\n            )\n        await runner.setup()\n\n        ctx = self._create_ssl_context(self.cfg) if self.cfg.is_ssl else None\n\n        runner = runner\n        assert runner is not None\n        server = runner.server\n        assert server is not None\n        for sock in self.sockets:\n            site = web.SockSite(\n                runner,\n                sock,\n                ssl_context=ctx,\n                shutdown_timeout=self.cfg.graceful_timeout / 100 * 95,\n            )\n            await site.start()\n\n        # If our parent changed then we shut down.\n        pid = os.getpid()\n        try:\n            while self.alive:  # type: ignore[has-type]\n                self.notify()\n\n                cnt = server.requests_count\n                if self.cfg.max_requests and cnt > self.cfg.max_requests:\n                    self.alive = False\n                    self.log.info(\"Max requests, shutting down: %s\", self)\n\n                elif pid == os.getpid() and self.ppid != os.getppid():\n                    self.alive = False\n                    self.log.info(\"Parent changed, shutting down: %s\", self)\n                else:\n                    await self._wait_next_notify()\n        except BaseException:\n            pass\n\n        await runner.cleanup()\n\n    def _wait_next_notify(self) -> \"asyncio.Future[bool]\":\n        self._notify_waiter_done()\n\n        loop = self.loop\n        assert loop is not None\n        self._notify_waiter = waiter = loop.create_future()\n        self.loop.call_later(1.0, self._notify_waiter_done, waiter)\n\n        return waiter\n\n    def _notify_waiter_done(\n        self, waiter: Optional[\"asyncio.Future[bool]\"] = None\n    ) -> None:\n        if waiter is None:\n            waiter = self._notify_waiter\n        if waiter is not None:\n            set_result(waiter, True)\n\n        if waiter is self._notify_waiter:\n            self._notify_waiter = None\n\n    def init_signals(self) -> None:\n        # Set up signals through the event loop API.\n\n        self.loop.add_signal_handler(\n            signal.SIGQUIT, self.handle_quit, signal.SIGQUIT, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGTERM, self.handle_exit, signal.SIGTERM, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGINT, self.handle_quit, signal.SIGINT, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGWINCH, self.handle_winch, signal.SIGWINCH, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGUSR1, self.handle_usr1, signal.SIGUSR1, None\n        )\n\n        self.loop.add_signal_handler(\n            signal.SIGABRT, self.handle_abort, signal.SIGABRT, None\n        )\n\n        # Don't let SIGTERM and SIGUSR1 disturb active requests\n        # by interrupting system calls\n        signal.siginterrupt(signal.SIGTERM, False)\n        signal.siginterrupt(signal.SIGUSR1, False)\n        # Reset signals so Gunicorn doesn't swallow subprocess return codes\n        # See: https://github.com/aio-libs/aiohttp/issues/6130\n\n    def handle_quit(self, sig: int, frame: Optional[FrameType]) -> None:\n        self.alive = False\n\n        # worker_int callback\n        self.cfg.worker_int(self)\n\n        # wakeup closing process\n        self._notify_waiter_done()\n\n    def handle_abort(self, sig: int, frame: Optional[FrameType]) -> None:\n        self.alive = False\n        self.exit_code = 1\n        self.cfg.worker_abort(self)\n        sys.exit(1)\n\n    @staticmethod\n    def _create_ssl_context(cfg: Any) -> \"SSLContext\":\n        \"\"\"Creates SSLContext instance for usage in asyncio.create_server.\n\n        See ssl.SSLSocket.__init__ for more details.\n        \"\"\"\n        if ssl is None:  # pragma: no cover\n            raise RuntimeError(\"SSL is not supported.\")\n\n        ctx = ssl.SSLContext(cfg.ssl_version)\n        ctx.load_cert_chain(cfg.certfile, cfg.keyfile)\n        ctx.verify_mode = cfg.cert_reqs\n        if cfg.ca_certs:\n            ctx.load_verify_locations(cfg.ca_certs)\n        if cfg.ciphers:\n            ctx.set_ciphers(cfg.ciphers)\n        return ctx\n\n    def _get_valid_log_format(self, source_format: str) -> str:\n        if source_format == self.DEFAULT_GUNICORN_LOG_FORMAT:\n            return self.DEFAULT_AIOHTTP_LOG_FORMAT\n        elif re.search(r\"%\\([^\\)]+\\)\", source_format):\n            raise ValueError(\n                \"Gunicorn's style options in form of `%(name)s` are not \"\n                \"supported for the log formatting. Please use aiohttp's \"\n                \"format specification to configure access log formatting: \"\n                \"http://docs.aiohttp.org/en/stable/logging.html\"\n                \"#format-specification\"\n            )\n        else:\n            return source_format\n\n\nclass GunicornUVLoopWebWorker(GunicornWebWorker):\n    def init_process(self) -> None:\n        import uvloop\n\n        # Close any existing event loop before setting a\n        # new policy.\n        asyncio.get_event_loop().close()\n\n        # Setup uvloop policy, so that every\n        # asyncio.get_event_loop() will create an instance\n        # of uvloop event loop.\n        asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())\n\n        super().init_process()\n"}
A user will ask you to solve a task. You should first draft your thinking process (inner monologue). Then, generate the solution.

Your response format must follow the template below:
<think>
Your thoughts or/and draft, like working through an exercise on scratch paper. Be as casual and as long as you want until you are confident to generate a correct solution.
</think>
<solution>
Final solution presented to the user.
</solution>
system
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]
**Title:** `max_requests_jitter` Parameter in `GunicornWebWorker` Not Taking Effect

**Description**

When configuring the `GunicornWebWorker` with the `max_requests_jitter` parameter, the jitter is not applied correctly. This results in the worker not shutting down as expected after reaching the maximum number of requests, which can lead to unintended prolonged runtimes.

**Example Code**

```python
worker.max_requests = 0
worker.cfg.access_log_format = ACCEPTABLE_LOG_FORMAT
worker.cfg.is_ssl = False

await worker._run()

# Expected: The worker should log "Parent changed, shutting down: <Worker>" and terminate.
# Actual: The log message is not called, and the worker does not shut down.
```

**Expected Behavior**

When `max_requests_jitter` is set, the `GunicornWebWorker` should apply the jitter to the `max_requests` limit. Upon reaching the adjusted request count, the worker should log an informational message indicating it is shutting down and then terminate gracefully.

**Actual Behavior**

The `max_requests_jitter` parameter does not influence the worker's behavior because the worker incorrectly references `self.cfg.max_requests` instead of `self.max_requests`. Consequently, the worker does not log the shutdown message and remains active beyond the intended request limit.
[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### aiohttp/worker.py
"""Async gunicorn worker for aiohttp.web"""

import asyncio
import os
import re
import signal
import sys
from types import FrameType
from typing import Any, Awaitable, Callable, Optional, Union  # noqa

from gunicorn.config import AccessLogFormat as GunicornAccessLogFormat
from gunicorn.workers import base

from aiohttp import web

from .helpers import set_result
from .web_app import Application
from .web_log import AccessLogger

try:
    import ssl

    SSLContext = ssl.SSLContext
except ImportError:  # pragma: no cover
    ssl = None  # type: ignore[assignment]
    SSLContext = object  # type: ignore[misc,assignment]


__all__ = ("GunicornWebWorker", "GunicornUVLoopWebWorker")


class GunicornWebWorker(base.Worker):  # type: ignore[misc,no-any-unimported]

    DEFAULT_AIOHTTP_LOG_FORMAT = AccessLogger.LOG_FORMAT
    DEFAULT_GUNICORN_LOG_FORMAT = GunicornAccessLogFormat.default

    def __init__(self, *args: Any, **kw: Any) -> None:  # pragma: no cover
        super().__init__(*args, **kw)

        self._task: Optional[asyncio.Task[None]] = None
        self.exit_code = 0
        self._notify_waiter: Optional[asyncio.Future[bool]] = None

    def init_process(self) -> None:
        # create new event_loop after fork
        asyncio.get_event_loop().close()

        self.loop = asyncio.new_event_loop()
        asyncio.set_event_loop(self.loop)

        super().init_process()

    def run(self) -> None:
        self._task = self.loop.create_task(self._run())

        try:  # ignore all finalization problems
            self.loop.run_until_complete(self._task)
        except Exception:
            self.log.exception("Exception in gunicorn worker")
        self.loop.run_until_complete(self.loop.shutdown_asyncgens())
        self.loop.close()

        sys.exit(self.exit_code)

    async def _run(self) -> None:
        runner = None
        if isinstance(self.wsgi, Application):
            app = self.wsgi
        elif asyncio.iscoroutinefunction(self.wsgi):
            wsgi = await self.wsgi()
            if isinstance(wsgi, web.AppRunner):
                runner = wsgi
                app = runner.app
            else:
                app = wsgi
        else:
            raise RuntimeError(
                "wsgi app should be either Application or "
                "async function returning Application, got {}".format(self.wsgi)
            )

        if runner is None:
            access_log = self.log.access_log if self.cfg.accesslog else None
            runner = web.AppRunner(
                app,
                logger=self.log,
                keepalive_timeout=self.cfg.keepalive,
                access_log=access_log,
                access_log_format=self._get_valid_log_format(
                    self.cfg.access_log_format
                ),
            )
        await runner.setup()

        ctx = self._create_ssl_context(self.cfg) if self.cfg.is_ssl else None

        runner = runner
        assert runner is not None
        server = runner.server
        assert server is not None
        for sock in self.sockets:
            site = web.SockSite(
                runner,
                sock,
                ssl_context=ctx,
                shutdown_timeout=self.cfg.graceful_timeout / 100 * 95,
            )
            await site.start()

        # If our parent changed then we shut down.
        pid = os.getpid()
        try:
            while self.alive:  # type: ignore[has-type]
                self.notify()

                cnt = server.requests_count
                if self.cfg.max_requests and cnt > self.cfg.max_requests:
                    self.alive = False
                    self.log.info("Max requests, shutting down: %s", self)

                elif pid == os.getpid() and self.ppid != os.getppid():
                    self.alive = False
                    self.log.info("Parent changed, shutting down: %s", self)
                else:
                    await self._wait_next_notify()
        except BaseException:
            pass

        await runner.cleanup()

    def _wait_next_notify(self) -> "asyncio.Future[bool]":
        self._notify_waiter_done()

        loop = self.loop
        assert loop is not None
        self._notify_waiter = waiter = loop.create_future()
        self.loop.call_later(1.0, self._notify_waiter_done, waiter)

        return waiter

    def _notify_waiter_done(
        self, waiter: Optional["asyncio.Future[bool]"] = None
    ) -> None:
        if waiter is None:
            waiter = self._notify_waiter
        if waiter is not None:
            set_result(waiter, True)

        if waiter is self._notify_waiter:
            self._notify_waiter = None

    def init_signals(self) -> None:
        # Set up signals through the event loop API.

        self.loop.add_signal_handler(
            signal.SIGQUIT, self.handle_quit, signal.SIGQUIT, None
        )

        self.loop.add_signal_handler(
            signal.SIGTERM, self.handle_exit, signal.SIGTERM, None
        )

        self.loop.add_signal_handler(
            signal.SIGINT, self.handle_quit, signal.SIGINT, None
        )

        self.loop.add_signal_handler(
            signal.SIGWINCH, self.handle_winch, signal.SIGWINCH, None
        )

        self.loop.add_signal_handler(
            signal.SIGUSR1, self.handle_usr1, signal.SIGUSR1, None
        )

        self.loop.add_signal_handler(
            signal.SIGABRT, self.handle_abort, signal.SIGABRT, None
        )

        # Don't let SIGTERM and SIGUSR1 disturb active requests
        # by interrupting system calls
        signal.siginterrupt(signal.SIGTERM, False)
        signal.siginterrupt(signal.SIGUSR1, False)
        # Reset signals so Gunicorn doesn't swallow subprocess return codes
        # See: https://github.com/aio-libs/aiohttp/issues/6130

    def handle_quit(self, sig: int, frame: Optional[FrameType]) -> None:
        self.alive = False

        # worker_int callback
        self.cfg.worker_int(self)

        # wakeup closing process
        self._notify_waiter_done()

    def handle_abort(self, sig: int, frame: Optional[FrameType]) -> None:
        self.alive = False
        self.exit_code = 1
        self.cfg.worker_abort(self)
        sys.exit(1)

    @staticmethod
    def _create_ssl_context(cfg: Any) -> "SSLContext":
        """Creates SSLContext instance for usage in asyncio.create_server.

        See ssl.SSLSocket.__init__ for more details.
        """
        if ssl is None:  # pragma: no cover
            raise RuntimeError("SSL is not supported.")

        ctx = ssl.SSLContext(cfg.ssl_version)
        ctx.load_cert_chain(cfg.certfile, cfg.keyfile)
        ctx.verify_mode = cfg.cert_reqs
        if cfg.ca_certs:
            ctx.load_verify_locations(cfg.ca_certs)
        if cfg.ciphers:
            ctx.set_ciphers(cfg.ciphers)
        return ctx

    def _get_valid_log_format(self, source_format: str) -> str:
        if source_format == self.DEFAULT_GUNICORN_LOG_FORMAT:
            return self.DEFAULT_AIOHTTP_LOG_FORMAT
        elif re.search(r"%\([^\)]+\)", source_format):
            raise ValueError(
                "Gunicorn's style options in form of `%(name)s` are not "
                "supported for the log formatting. Please use aiohttp's "
                "format specification to configure access log formatting: "
                "http://docs.aiohttp.org/en/stable/logging.html"
                "#format-specification"
            )
        else:
            return source_format


class GunicornUVLoopWebWorker(GunicornWebWorker):
    def init_process(self) -> None:
        import uvloop

        # Close any existing event loop before setting a
        # new policy.
        asyncio.get_event_loop().close()

        # Setup uvloop policy, so that every
        # asyncio.get_event_loop() will create an instance
        # of uvloop event loop.
        asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())

        super().init_process()

```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
user