diff --git a/sanic/server/loop.py b/sanic/server/loop.py index 5613f709..72b6f063 100644 --- a/sanic/server/loop.py +++ b/sanic/server/loop.py @@ -1,12 +1,25 @@ import asyncio -from distutils.util import strtobool from os import getenv from sanic.compat import OS_IS_WINDOWS from sanic.log import error_logger +def strtobool(query: str) -> bool: + """ + reimplement strtobool per PEP 632 and python 3.12 deprecation + + True values are y, yes, t, true, on and 1; false values are n, no, f, false, off and 0. Raises ValueError if val is anything else. + """ + if query.lower() in ["y", "yes", "t", "true", "on", "1"]: + return True + elif query.lower() in ["n", "no", "f", "false", "off", "0"]: + return False + else: + raise ValueError + + def try_use_uvloop() -> None: """ Use uvloop instead of the default asyncio loop.