We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
distutils.strtobool deprecation 
**Describe the bug**
he distutils package is deprecated and slated for removal in Python 3.12. [PEP 632](https://www.python.org/dev/peps/pep-0632/)

**Code snippet**
[sanic/server/loop.py](https://github.com/sanic-org/sanic/blob/ac388d644b1e22156e228470fad8ea34932c080a/sanic/server/loop.py#L3)

**Expected behavior**
A lack of warnings about deprecation

**Environment (please complete the following information):**
 - OS: All
 - Version: All supported as of 2022/01/23 

**Additional context**
This is housekeeping to clean up a core python deprecation.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `setup.py`
Content:
```
1 """
2 Sanic
3 """
4 import codecs
5 import os
6 import re
7 import sys
8 
9 from distutils.util import strtobool
10 
11 from setuptools import find_packages, setup
12 from setuptools.command.test import test as TestCommand
13 
14 
15 class PyTest(TestCommand):
16     """
17     Provide a Test runner to be used from setup.py to run unit tests
18     """
19 
20     user_options = [("pytest-args=", "a", "Arguments to pass to pytest")]
21 
22     def initialize_options(self):
23         TestCommand.initialize_options(self)
24         self.pytest_args = ""
25 
26     def run_tests(self):
27         import shlex
28 
29         import pytest
30 
31         errno = pytest.main(shlex.split(self.pytest_args))
32         sys.exit(errno)
33 
34 
35 def open_local(paths, mode="r", encoding="utf8"):
36     path = os.path.join(os.path.abspath(os.path.dirname(__file__)), *paths)
37 
38     return codecs.open(path, mode, encoding)
39 
40 
41 with open_local(["sanic", "__version__.py"], encoding="latin1") as fp:
42     try:
43         version = re.findall(
44             r"^__version__ = \"([^']+)\"\r?$", fp.read(), re.M
45         )[0]
46     except IndexError:
47         raise RuntimeError("Unable to determine version.")
48 
49 with open_local(["README.rst"]) as rm:
50     long_description = rm.read()
51 
52 setup_kwargs = {
53     "name": "sanic",
54     "version": version,
55     "url": "http://github.com/sanic-org/sanic/",
56     "license": "MIT",
57     "author": "Sanic Community",
58     "author_email": "admhpkns@gmail.com",
59     "description": (
60         "A web server and web framework that's written to go fast. "
61         "Build fast. Run fast."
62     ),
63     "long_description": long_description,
64     "packages": find_packages(exclude=("tests", "tests.*")),
65     "package_data": {"sanic": ["py.typed"]},
66     "platforms": "any",
67     "python_requires": ">=3.7",
68     "classifiers": [
69         "Development Status :: 4 - Beta",
70         "Environment :: Web Environment",
71         "License :: OSI Approved :: MIT License",
72         "Programming Language :: Python :: 3.7",
73         "Programming Language :: Python :: 3.8",
74         "Programming Language :: Python :: 3.9",
75         "Programming Language :: Python :: 3.10",
76     ],
77     "entry_points": {"console_scripts": ["sanic = sanic.__main__:main"]},
78 }
79 
80 env_dependency = (
81     '; sys_platform != "win32" ' 'and implementation_name == "cpython"'
82 )
83 ujson = "ujson>=1.35" + env_dependency
84 uvloop = "uvloop>=0.15.0" + env_dependency
85 types_ujson = "types-ujson" + env_dependency
86 requirements = [
87     "sanic-routing>=22.8.0",
88     "httptools>=0.0.10",
89     uvloop,
90     ujson,
91     "aiofiles>=0.6.0",
92     "websockets>=10.0",
93     "multidict>=5.0,<7.0",
94 ]
95 
96 tests_require = [
97     "sanic-testing>=22.9.0",
98     "pytest==7.1.*",
99     "coverage",
100     "beautifulsoup4",
101     "pytest-sanic",
102     "pytest-benchmark",
103     "chardet==3.*",
104     "flake8",
105     "black",
106     "isort>=5.0.0",
107     "bandit",
108     "mypy>=0.901,<0.910",
109     "docutils",
110     "pygments",
111     "uvicorn<0.15.0",
112     "slotscheck>=0.8.0,<1",
113     types_ujson,
114 ]
115 
116 docs_require = [
117     "sphinx>=2.1.2",
118     "sphinx_rtd_theme>=0.4.3",
119     "docutils",
120     "pygments",
121     "m2r2",
122     "enum-tools[sphinx]",
123     "mistune<2.0.0",
124 ]
125 
126 dev_require = tests_require + [
127     "cryptography",
128     "tox",
129     "towncrier",
130 ]
131 
132 all_require = list(set(dev_require + docs_require))
133 
134 if strtobool(os.environ.get("SANIC_NO_UJSON", "no")):
135     print("Installing without uJSON")
136     requirements.remove(ujson)
137     tests_require.remove(types_ujson)
138 
139 # 'nt' means windows OS
140 if strtobool(os.environ.get("SANIC_NO_UVLOOP", "no")):
141     print("Installing without uvLoop")
142     requirements.remove(uvloop)
143 
144 extras_require = {
145     "test": tests_require,
146     "dev": dev_require,
147     "docs": docs_require,
148     "all": all_require,
149     "ext": ["sanic-ext"],
150     "http3": ["aioquic"],
151 }
152 
153 setup_kwargs["install_requires"] = requirements
154 setup_kwargs["tests_require"] = tests_require
155 setup_kwargs["extras_require"] = extras_require
156 setup_kwargs["cmdclass"] = {"test": PyTest}
157 setup(**setup_kwargs)
158
```

Path: `sanic/server/loop.py`
Content:
```
1 import asyncio
2 import sys
3 
4 from distutils.util import strtobool
5 from os import getenv
6 
7 from sanic.compat import OS_IS_WINDOWS
8 from sanic.log import error_logger
9 
10 
11 def try_use_uvloop() -> None:
12     """
13     Use uvloop instead of the default asyncio loop.
14     """
15     if OS_IS_WINDOWS:
16         error_logger.warning(
17             "You are trying to use uvloop, but uvloop is not compatible "
18             "with your system. You can disable uvloop completely by setting "
19             "the 'USE_UVLOOP' configuration value to false, or simply not "
20             "defining it and letting Sanic handle it for you. Sanic will now "
21             "continue to run using the default event loop."
22         )
23         return
24 
25     try:
26         import uvloop  # type: ignore
27     except ImportError:
28         error_logger.warning(
29             "You are trying to use uvloop, but uvloop is not "
30             "installed in your system. In order to use uvloop "
31             "you must first install it. Otherwise, you can disable "
32             "uvloop completely by setting the 'USE_UVLOOP' "
33             "configuration value to false. Sanic will now continue "
34             "to run with the default event loop."
35         )
36         return
37 
38     uvloop_install_removed = strtobool(getenv("SANIC_NO_UVLOOP", "no"))
39     if uvloop_install_removed:
40         error_logger.info(
41             "You are requesting to run Sanic using uvloop, but the "
42             "install-time 'SANIC_NO_UVLOOP' environment variable (used to "
43             "opt-out of installing uvloop with Sanic) is set to true. If "
44             "you want to prevent Sanic from overriding the event loop policy "
45             "during runtime, set the 'USE_UVLOOP' configuration value to "
46             "false."
47         )
48 
49     if not isinstance(asyncio.get_event_loop_policy(), uvloop.EventLoopPolicy):
50         asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
51 
52 
53 def try_windows_loop():
54     if not OS_IS_WINDOWS:
55         error_logger.warning(
56             "You are trying to use an event loop policy that is not "
57             "compatible with your system. You can simply let Sanic handle "
58             "selecting the best loop for you. Sanic will now continue to run "
59             "using the default event loop."
60         )
61         return
62 
63     if sys.version_info >= (3, 8) and not isinstance(
64         asyncio.get_event_loop_policy(), asyncio.WindowsSelectorEventLoopPolicy
65     ):
66         asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
67
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/sanic/server/loop.py b/sanic/server/loop.py
--- a/sanic/server/loop.py
+++ b/sanic/server/loop.py
@@ -1,11 +1,11 @@
 import asyncio
 import sys
 
-from distutils.util import strtobool
 from os import getenv
 
 from sanic.compat import OS_IS_WINDOWS
 from sanic.log import error_logger
+from sanic.utils import str_to_bool
 
 
 def try_use_uvloop() -> None:
@@ -35,7 +35,7 @@
         )
         return
 
-    uvloop_install_removed = strtobool(getenv("SANIC_NO_UVLOOP", "no"))
+    uvloop_install_removed = str_to_bool(getenv("SANIC_NO_UVLOOP", "no"))
     if uvloop_install_removed:
         error_logger.info(
             "You are requesting to run Sanic using uvloop, but the "
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -6,8 +6,6 @@
 import re
 import sys
 
-from distutils.util import strtobool
-
 from setuptools import find_packages, setup
 from setuptools.command.test import test as TestCommand
 
@@ -37,6 +35,25 @@
 
     return codecs.open(path, mode, encoding)
 
+def str_to_bool(val: str) -> bool:
+    val = val.lower()
+    if val in {
+        "y",
+        "yes",
+        "yep",
+        "yup",
+        "t",
+        "true",
+        "on",
+        "enable",
+        "enabled",
+        "1",
+    }:
+        return True
+    elif val in {"n", "no", "f", "false", "off", "disable", "disabled", "0"}:
+        return False
+    else:
+        raise ValueError(f"Invalid truth value {val}")
 
 with open_local(["sanic", "__version__.py"], encoding="latin1") as fp:
     try:
@@ -131,13 +148,13 @@
 
 all_require = list(set(dev_require + docs_require))
 
-if strtobool(os.environ.get("SANIC_NO_UJSON", "no")):
+if str_to_bool(os.environ.get("SANIC_NO_UJSON", "no")):
     print("Installing without uJSON")
     requirements.remove(ujson)
     tests_require.remove(types_ujson)
 
 # 'nt' means windows OS
-if strtobool(os.environ.get("SANIC_NO_UVLOOP", "no")):
+if str_to_bool(os.environ.get("SANIC_NO_UVLOOP", "no")):
     print("Installing without uvLoop")
     requirements.remove(uvloop)

{"golden_diff": "diff --git a/sanic/server/loop.py b/sanic/server/loop.py\n--- a/sanic/server/loop.py\n+++ b/sanic/server/loop.py\n@@ -1,11 +1,11 @@\n import asyncio\n import sys\n \n-from distutils.util import strtobool\n from os import getenv\n \n from sanic.compat import OS_IS_WINDOWS\n from sanic.log import error_logger\n+from sanic.utils import str_to_bool\n \n \n def try_use_uvloop() -> None:\n@@ -35,7 +35,7 @@\n         )\n         return\n \n-    uvloop_install_removed = strtobool(getenv(\"SANIC_NO_UVLOOP\", \"no\"))\n+    uvloop_install_removed = str_to_bool(getenv(\"SANIC_NO_UVLOOP\", \"no\"))\n     if uvloop_install_removed:\n         error_logger.info(\n             \"You are requesting to run Sanic using uvloop, but the \"\ndiff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -6,8 +6,6 @@\n import re\n import sys\n \n-from distutils.util import strtobool\n-\n from setuptools import find_packages, setup\n from setuptools.command.test import test as TestCommand\n \n@@ -37,6 +35,25 @@\n \n     return codecs.open(path, mode, encoding)\n \n+def str_to_bool(val: str) -> bool:\n+    val = val.lower()\n+    if val in {\n+        \"y\",\n+        \"yes\",\n+        \"yep\",\n+        \"yup\",\n+        \"t\",\n+        \"true\",\n+        \"on\",\n+        \"enable\",\n+        \"enabled\",\n+        \"1\",\n+    }:\n+        return True\n+    elif val in {\"n\", \"no\", \"f\", \"false\", \"off\", \"disable\", \"disabled\", \"0\"}:\n+        return False\n+    else:\n+        raise ValueError(f\"Invalid truth value {val}\")\n \n with open_local([\"sanic\", \"__version__.py\"], encoding=\"latin1\") as fp:\n     try:\n@@ -131,13 +148,13 @@\n \n all_require = list(set(dev_require + docs_require))\n \n-if strtobool(os.environ.get(\"SANIC_NO_UJSON\", \"no\")):\n+if str_to_bool(os.environ.get(\"SANIC_NO_UJSON\", \"no\")):\n     print(\"Installing without uJSON\")\n     requirements.remove(ujson)\n     tests_require.remove(types_ujson)\n \n # 'nt' means windows OS\n-if strtobool(os.environ.get(\"SANIC_NO_UVLOOP\", \"no\")):\n+if str_to_bool(os.environ.get(\"SANIC_NO_UVLOOP\", \"no\")):\n     print(\"Installing without uvLoop\")\n     requirements.remove(uvloop)\n", "issue": "distutils.strtobool deprecation \n**Describe the bug**\r\nhe distutils package is deprecated and slated for removal in Python 3.12. [PEP 632](https://www.python.org/dev/peps/pep-0632/)\r\n\r\n**Code snippet**\r\n[sanic/server/loop.py](https://github.com/sanic-org/sanic/blob/ac388d644b1e22156e228470fad8ea34932c080a/sanic/server/loop.py#L3)\r\n\r\n**Expected behavior**\r\nA lack of warnings about deprecation\r\n\r\n**Environment (please complete the following information):**\r\n - OS: All\r\n - Version: All supported as of 2022/01/23 \r\n\r\n**Additional context**\r\nThis is housekeeping to clean up a core python deprecation.\r\n\n", "before_files": [{"content": "\"\"\"\nSanic\n\"\"\"\nimport codecs\nimport os\nimport re\nimport sys\n\nfrom distutils.util import strtobool\n\nfrom setuptools import find_packages, setup\nfrom setuptools.command.test import test as TestCommand\n\n\nclass PyTest(TestCommand):\n    \"\"\"\n    Provide a Test runner to be used from setup.py to run unit tests\n    \"\"\"\n\n    user_options = [(\"pytest-args=\", \"a\", \"Arguments to pass to pytest\")]\n\n    def initialize_options(self):\n        TestCommand.initialize_options(self)\n        self.pytest_args = \"\"\n\n    def run_tests(self):\n        import shlex\n\n        import pytest\n\n        errno = pytest.main(shlex.split(self.pytest_args))\n        sys.exit(errno)\n\n\ndef open_local(paths, mode=\"r\", encoding=\"utf8\"):\n    path = os.path.join(os.path.abspath(os.path.dirname(__file__)), *paths)\n\n    return codecs.open(path, mode, encoding)\n\n\nwith open_local([\"sanic\", \"__version__.py\"], encoding=\"latin1\") as fp:\n    try:\n        version = re.findall(\n            r\"^__version__ = \\\"([^']+)\\\"\\r?$\", fp.read(), re.M\n        )[0]\n    except IndexError:\n        raise RuntimeError(\"Unable to determine version.\")\n\nwith open_local([\"README.rst\"]) as rm:\n    long_description = rm.read()\n\nsetup_kwargs = {\n    \"name\": \"sanic\",\n    \"version\": version,\n    \"url\": \"http://github.com/sanic-org/sanic/\",\n    \"license\": \"MIT\",\n    \"author\": \"Sanic Community\",\n    \"author_email\": \"admhpkns@gmail.com\",\n    \"description\": (\n        \"A web server and web framework that's written to go fast. \"\n        \"Build fast. Run fast.\"\n    ),\n    \"long_description\": long_description,\n    \"packages\": find_packages(exclude=(\"tests\", \"tests.*\")),\n    \"package_data\": {\"sanic\": [\"py.typed\"]},\n    \"platforms\": \"any\",\n    \"python_requires\": \">=3.7\",\n    \"classifiers\": [\n        \"Development Status :: 4 - Beta\",\n        \"Environment :: Web Environment\",\n        \"License :: OSI Approved :: MIT License\",\n        \"Programming Language :: Python :: 3.7\",\n        \"Programming Language :: Python :: 3.8\",\n        \"Programming Language :: Python :: 3.9\",\n        \"Programming Language :: Python :: 3.10\",\n    ],\n    \"entry_points\": {\"console_scripts\": [\"sanic = sanic.__main__:main\"]},\n}\n\nenv_dependency = (\n    '; sys_platform != \"win32\" ' 'and implementation_name == \"cpython\"'\n)\nujson = \"ujson>=1.35\" + env_dependency\nuvloop = \"uvloop>=0.15.0\" + env_dependency\ntypes_ujson = \"types-ujson\" + env_dependency\nrequirements = [\n    \"sanic-routing>=22.8.0\",\n    \"httptools>=0.0.10\",\n    uvloop,\n    ujson,\n    \"aiofiles>=0.6.0\",\n    \"websockets>=10.0\",\n    \"multidict>=5.0,<7.0\",\n]\n\ntests_require = [\n    \"sanic-testing>=22.9.0\",\n    \"pytest==7.1.*\",\n    \"coverage\",\n    \"beautifulsoup4\",\n    \"pytest-sanic\",\n    \"pytest-benchmark\",\n    \"chardet==3.*\",\n    \"flake8\",\n    \"black\",\n    \"isort>=5.0.0\",\n    \"bandit\",\n    \"mypy>=0.901,<0.910\",\n    \"docutils\",\n    \"pygments\",\n    \"uvicorn<0.15.0\",\n    \"slotscheck>=0.8.0,<1\",\n    types_ujson,\n]\n\ndocs_require = [\n    \"sphinx>=2.1.2\",\n    \"sphinx_rtd_theme>=0.4.3\",\n    \"docutils\",\n    \"pygments\",\n    \"m2r2\",\n    \"enum-tools[sphinx]\",\n    \"mistune<2.0.0\",\n]\n\ndev_require = tests_require + [\n    \"cryptography\",\n    \"tox\",\n    \"towncrier\",\n]\n\nall_require = list(set(dev_require + docs_require))\n\nif strtobool(os.environ.get(\"SANIC_NO_UJSON\", \"no\")):\n    print(\"Installing without uJSON\")\n    requirements.remove(ujson)\n    tests_require.remove(types_ujson)\n\n# 'nt' means windows OS\nif strtobool(os.environ.get(\"SANIC_NO_UVLOOP\", \"no\")):\n    print(\"Installing without uvLoop\")\n    requirements.remove(uvloop)\n\nextras_require = {\n    \"test\": tests_require,\n    \"dev\": dev_require,\n    \"docs\": docs_require,\n    \"all\": all_require,\n    \"ext\": [\"sanic-ext\"],\n    \"http3\": [\"aioquic\"],\n}\n\nsetup_kwargs[\"install_requires\"] = requirements\nsetup_kwargs[\"tests_require\"] = tests_require\nsetup_kwargs[\"extras_require\"] = extras_require\nsetup_kwargs[\"cmdclass\"] = {\"test\": PyTest}\nsetup(**setup_kwargs)\n", "path": "setup.py"}, {"content": "import asyncio\nimport sys\n\nfrom distutils.util import strtobool\nfrom os import getenv\n\nfrom sanic.compat import OS_IS_WINDOWS\nfrom sanic.log import error_logger\n\n\ndef try_use_uvloop() -> None:\n    \"\"\"\n    Use uvloop instead of the default asyncio loop.\n    \"\"\"\n    if OS_IS_WINDOWS:\n        error_logger.warning(\n            \"You are trying to use uvloop, but uvloop is not compatible \"\n            \"with your system. You can disable uvloop completely by setting \"\n            \"the 'USE_UVLOOP' configuration value to false, or simply not \"\n            \"defining it and letting Sanic handle it for you. Sanic will now \"\n            \"continue to run using the default event loop.\"\n        )\n        return\n\n    try:\n        import uvloop  # type: ignore\n    except ImportError:\n        error_logger.warning(\n            \"You are trying to use uvloop, but uvloop is not \"\n            \"installed in your system. In order to use uvloop \"\n            \"you must first install it. Otherwise, you can disable \"\n            \"uvloop completely by setting the 'USE_UVLOOP' \"\n            \"configuration value to false. Sanic will now continue \"\n            \"to run with the default event loop.\"\n        )\n        return\n\n    uvloop_install_removed = strtobool(getenv(\"SANIC_NO_UVLOOP\", \"no\"))\n    if uvloop_install_removed:\n        error_logger.info(\n            \"You are requesting to run Sanic using uvloop, but the \"\n            \"install-time 'SANIC_NO_UVLOOP' environment variable (used to \"\n            \"opt-out of installing uvloop with Sanic) is set to true. If \"\n            \"you want to prevent Sanic from overriding the event loop policy \"\n            \"during runtime, set the 'USE_UVLOOP' configuration value to \"\n            \"false.\"\n        )\n\n    if not isinstance(asyncio.get_event_loop_policy(), uvloop.EventLoopPolicy):\n        asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())\n\n\ndef try_windows_loop():\n    if not OS_IS_WINDOWS:\n        error_logger.warning(\n            \"You are trying to use an event loop policy that is not \"\n            \"compatible with your system. You can simply let Sanic handle \"\n            \"selecting the best loop for you. Sanic will now continue to run \"\n            \"using the default event loop.\"\n        )\n        return\n\n    if sys.version_info >= (3, 8) and not isinstance(\n        asyncio.get_event_loop_policy(), asyncio.WindowsSelectorEventLoopPolicy\n    ):\n        asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())\n", "path": "sanic/server/loop.py"}], "after_files": [{"content": "\"\"\"\nSanic\n\"\"\"\nimport codecs\nimport os\nimport re\nimport sys\n\nfrom setuptools import find_packages, setup\nfrom setuptools.command.test import test as TestCommand\n\n\nclass PyTest(TestCommand):\n    \"\"\"\n    Provide a Test runner to be used from setup.py to run unit tests\n    \"\"\"\n\n    user_options = [(\"pytest-args=\", \"a\", \"Arguments to pass to pytest\")]\n\n    def initialize_options(self):\n        TestCommand.initialize_options(self)\n        self.pytest_args = \"\"\n\n    def run_tests(self):\n        import shlex\n\n        import pytest\n\n        errno = pytest.main(shlex.split(self.pytest_args))\n        sys.exit(errno)\n\n\ndef open_local(paths, mode=\"r\", encoding=\"utf8\"):\n    path = os.path.join(os.path.abspath(os.path.dirname(__file__)), *paths)\n\n    return codecs.open(path, mode, encoding)\n\ndef str_to_bool(val: str) -> bool:\n    val = val.lower()\n    if val in {\n        \"y\",\n        \"yes\",\n        \"yep\",\n        \"yup\",\n        \"t\",\n        \"true\",\n        \"on\",\n        \"enable\",\n        \"enabled\",\n        \"1\",\n    }:\n        return True\n    elif val in {\"n\", \"no\", \"f\", \"false\", \"off\", \"disable\", \"disabled\", \"0\"}:\n        return False\n    else:\n        raise ValueError(f\"Invalid truth value {val}\")\n\nwith open_local([\"sanic\", \"__version__.py\"], encoding=\"latin1\") as fp:\n    try:\n        version = re.findall(\n            r\"^__version__ = \\\"([^']+)\\\"\\r?$\", fp.read(), re.M\n        )[0]\n    except IndexError:\n        raise RuntimeError(\"Unable to determine version.\")\n\nwith open_local([\"README.rst\"]) as rm:\n    long_description = rm.read()\n\nsetup_kwargs = {\n    \"name\": \"sanic\",\n    \"version\": version,\n    \"url\": \"http://github.com/sanic-org/sanic/\",\n    \"license\": \"MIT\",\n    \"author\": \"Sanic Community\",\n    \"author_email\": \"admhpkns@gmail.com\",\n    \"description\": (\n        \"A web server and web framework that's written to go fast. \"\n        \"Build fast. Run fast.\"\n    ),\n    \"long_description\": long_description,\n    \"packages\": find_packages(exclude=(\"tests\", \"tests.*\")),\n    \"package_data\": {\"sanic\": [\"py.typed\"]},\n    \"platforms\": \"any\",\n    \"python_requires\": \">=3.7\",\n    \"classifiers\": [\n        \"Development Status :: 4 - Beta\",\n        \"Environment :: Web Environment\",\n        \"License :: OSI Approved :: MIT License\",\n        \"Programming Language :: Python :: 3.7\",\n        \"Programming Language :: Python :: 3.8\",\n        \"Programming Language :: Python :: 3.9\",\n        \"Programming Language :: Python :: 3.10\",\n    ],\n    \"entry_points\": {\"console_scripts\": [\"sanic = sanic.__main__:main\"]},\n}\n\nenv_dependency = (\n    '; sys_platform != \"win32\" ' 'and implementation_name == \"cpython\"'\n)\nujson = \"ujson>=1.35\" + env_dependency\nuvloop = \"uvloop>=0.15.0\" + env_dependency\ntypes_ujson = \"types-ujson\" + env_dependency\nrequirements = [\n    \"sanic-routing>=22.8.0\",\n    \"httptools>=0.0.10\",\n    uvloop,\n    ujson,\n    \"aiofiles>=0.6.0\",\n    \"websockets>=10.0\",\n    \"multidict>=5.0,<7.0\",\n]\n\ntests_require = [\n    \"sanic-testing>=22.9.0\",\n    \"pytest==7.1.*\",\n    \"coverage\",\n    \"beautifulsoup4\",\n    \"pytest-sanic\",\n    \"pytest-benchmark\",\n    \"chardet==3.*\",\n    \"flake8\",\n    \"black\",\n    \"isort>=5.0.0\",\n    \"bandit\",\n    \"mypy>=0.901,<0.910\",\n    \"docutils\",\n    \"pygments\",\n    \"uvicorn<0.15.0\",\n    \"slotscheck>=0.8.0,<1\",\n    types_ujson,\n]\n\ndocs_require = [\n    \"sphinx>=2.1.2\",\n    \"sphinx_rtd_theme>=0.4.3\",\n    \"docutils\",\n    \"pygments\",\n    \"m2r2\",\n    \"enum-tools[sphinx]\",\n    \"mistune<2.0.0\",\n]\n\ndev_require = tests_require + [\n    \"cryptography\",\n    \"tox\",\n    \"towncrier\",\n]\n\nall_require = list(set(dev_require + docs_require))\n\nif str_to_bool(os.environ.get(\"SANIC_NO_UJSON\", \"no\")):\n    print(\"Installing without uJSON\")\n    requirements.remove(ujson)\n    tests_require.remove(types_ujson)\n\n# 'nt' means windows OS\nif str_to_bool(os.environ.get(\"SANIC_NO_UVLOOP\", \"no\")):\n    print(\"Installing without uvLoop\")\n    requirements.remove(uvloop)\n\nextras_require = {\n    \"test\": tests_require,\n    \"dev\": dev_require,\n    \"docs\": docs_require,\n    \"all\": all_require,\n    \"ext\": [\"sanic-ext\"],\n    \"http3\": [\"aioquic\"],\n}\n\nsetup_kwargs[\"install_requires\"] = requirements\nsetup_kwargs[\"tests_require\"] = tests_require\nsetup_kwargs[\"extras_require\"] = extras_require\nsetup_kwargs[\"cmdclass\"] = {\"test\": PyTest}\nsetup(**setup_kwargs)\n", "path": "setup.py"}, {"content": "import asyncio\nimport sys\n\nfrom os import getenv\n\nfrom sanic.compat import OS_IS_WINDOWS\nfrom sanic.log import error_logger\nfrom sanic.utils import str_to_bool\n\n\ndef try_use_uvloop() -> None:\n    \"\"\"\n    Use uvloop instead of the default asyncio loop.\n    \"\"\"\n    if OS_IS_WINDOWS:\n        error_logger.warning(\n            \"You are trying to use uvloop, but uvloop is not compatible \"\n            \"with your system. You can disable uvloop completely by setting \"\n            \"the 'USE_UVLOOP' configuration value to false, or simply not \"\n            \"defining it and letting Sanic handle it for you. Sanic will now \"\n            \"continue to run using the default event loop.\"\n        )\n        return\n\n    try:\n        import uvloop  # type: ignore\n    except ImportError:\n        error_logger.warning(\n            \"You are trying to use uvloop, but uvloop is not \"\n            \"installed in your system. In order to use uvloop \"\n            \"you must first install it. Otherwise, you can disable \"\n            \"uvloop completely by setting the 'USE_UVLOOP' \"\n            \"configuration value to false. Sanic will now continue \"\n            \"to run with the default event loop.\"\n        )\n        return\n\n    uvloop_install_removed = str_to_bool(getenv(\"SANIC_NO_UVLOOP\", \"no\"))\n    if uvloop_install_removed:\n        error_logger.info(\n            \"You are requesting to run Sanic using uvloop, but the \"\n            \"install-time 'SANIC_NO_UVLOOP' environment variable (used to \"\n            \"opt-out of installing uvloop with Sanic) is set to true. If \"\n            \"you want to prevent Sanic from overriding the event loop policy \"\n            \"during runtime, set the 'USE_UVLOOP' configuration value to \"\n            \"false.\"\n        )\n\n    if not isinstance(asyncio.get_event_loop_policy(), uvloop.EventLoopPolicy):\n        asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())\n\n\ndef try_windows_loop():\n    if not OS_IS_WINDOWS:\n        error_logger.warning(\n            \"You are trying to use an event loop policy that is not \"\n            \"compatible with your system. You can simply let Sanic handle \"\n            \"selecting the best loop for you. Sanic will now continue to run \"\n            \"using the default event loop.\"\n        )\n        return\n\n    if sys.version_info >= (3, 8) and not isinstance(\n        asyncio.get_event_loop_policy(), asyncio.WindowsSelectorEventLoopPolicy\n    ):\n        asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())\n", "path": "sanic/server/loop.py"}]}