Merge pull request 'fix resource leaks' (#2191) from fix-warning into main
This commit is contained in:
@@ -71,8 +71,6 @@ class TimeTable:
|
||||
weakref.finalize(self, self.table_print)
|
||||
|
||||
def table_print(self) -> None:
|
||||
if os.getenv("PERF") != "1":
|
||||
return
|
||||
print("======== CMD TIMETABLE ========")
|
||||
|
||||
# Sort the table by time in descending order
|
||||
@@ -96,7 +94,9 @@ class TimeTable:
|
||||
self.table[cmd] = time
|
||||
|
||||
|
||||
TIME_TABLE = TimeTable()
|
||||
TIME_TABLE = None
|
||||
if os.environ.get("CLAN_CLI_PERF"):
|
||||
TIME_TABLE = TimeTable()
|
||||
|
||||
|
||||
def run(
|
||||
@@ -120,13 +120,13 @@ def run(
|
||||
tstart = datetime.datetime.now(tz=datetime.UTC)
|
||||
|
||||
# Start the subprocess
|
||||
process = subprocess.Popen(
|
||||
with subprocess.Popen(
|
||||
cmd,
|
||||
cwd=str(cwd),
|
||||
env=env,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
)
|
||||
) as process:
|
||||
stdout_buf, stderr_buf = handle_output(process, log)
|
||||
|
||||
if input:
|
||||
@@ -136,6 +136,7 @@ def run(
|
||||
tend = datetime.datetime.now(tz=datetime.UTC)
|
||||
|
||||
global TIME_TABLE
|
||||
if TIME_TABLE:
|
||||
TIME_TABLE.add(shlex.join(cmd), tend - tstart)
|
||||
|
||||
# Wait for the subprocess to finish
|
||||
|
||||
@@ -36,6 +36,7 @@ log_format = "%(levelname)s: %(message)s\n %(pathname)s:%(lineno)d::%(func
|
||||
addopts = "--cov . --cov-report term --cov-report html:.reports/html --no-cov-on-fail --durations 5 --color=yes --new-first -n auto" # Add --pdb for debugging
|
||||
norecursedirs = "tests/helpers"
|
||||
markers = ["impure", "with_core"]
|
||||
filterwarnings = "default::ResourceWarning"
|
||||
|
||||
[tool.mypy]
|
||||
python_version = "3.12"
|
||||
|
||||
Reference in New Issue
Block a user