Fix ResourceWarning
in moto.settings.is_docker()
. (#5060)
This commit is contained in:
parent
afe4b3ace9
commit
d12254309d
@ -1,5 +1,6 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import pathlib
|
||||||
|
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
|
|
||||||
@ -85,11 +86,11 @@ def test_server_mode_endpoint():
|
|||||||
|
|
||||||
|
|
||||||
def is_docker():
|
def is_docker():
|
||||||
path = "/proc/self/cgroup"
|
path = pathlib.Path("/proc/self/cgroup")
|
||||||
return (
|
return (
|
||||||
os.path.exists("/.dockerenv")
|
os.path.exists("/.dockerenv")
|
||||||
or os.path.isfile(path)
|
or path.is_file()
|
||||||
and any("docker" in line for line in open(path))
|
and any("docker" in line for line in path.read_text())
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user