Only stat the .dockerenv file once (#76097)

This commit is contained in:
J. Nick Koston 2022-08-02 10:38:01 -10:00 committed by Franck Nijhof
parent d2dc83c4c7
commit 51a6899a60
No known key found for this signature in database
GPG key ID: D62583BA8AB11CA3

View file

@ -2,6 +2,7 @@
from __future__ import annotations from __future__ import annotations
import asyncio import asyncio
from functools import cache
from importlib.metadata import PackageNotFoundError, version from importlib.metadata import PackageNotFoundError, version
import logging import logging
import os import os
@ -23,6 +24,7 @@ def is_virtual_env() -> bool:
) )
@cache
def is_docker_env() -> bool: def is_docker_env() -> bool:
"""Return True if we run in a docker env.""" """Return True if we run in a docker env."""
return Path("/.dockerenv").exists() return Path("/.dockerenv").exists()