Skip to content

Commit

Permalink
fix(backend): silent destruction of backends under continuous inference
Browse files Browse the repository at this point in the history
  • Loading branch information
TianyiQ committed Dec 21, 2024
1 parent b947abe commit fb7e2d4
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/abstractions/configs/templates_configs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from src.path import root
from string import Template
import json
import os
import os, sys
from typing import Dict, Any, Literal, Optional, List, Union, Callable


Expand Down Expand Up @@ -34,8 +34,17 @@ def __exit__(self, type, value, traceback):
for k, v in self.prior_state.items():
setattr(GlobalState, k, v)

for destroy in GlobalState.__active_backend_destroyers:
destroy()
# Keep silent when destroying backends if LOUD_BACKEND is not set
old_stdout, old_stderr = sys.stdout, sys.stderr
with open(os.devnull, "w") as devnull:
if not eval(os.environ.get("LOUD_BACKEND", "False")):
sys.stdout = devnull
sys.stderr = devnull

for destroy in GlobalState.__active_backend_destroyers:
destroy()

sys.stdout, sys.stderr = old_stdout, old_stderr

GlobalState.__active_backend_destroyers = []

Expand Down

0 comments on commit fb7e2d4

Please sign in to comment.