Skip to content

Commit

Permalink
Fix silent() not handling exceptions properly
Browse files Browse the repository at this point in the history
  • Loading branch information
HazardousPeach committed Mar 16, 2022
1 parent ed258b0 commit 16968d5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,11 @@ def silent():
save_stdout = sys.stdout
sys.stderr = DummyFile()
sys.stdout = DummyFile()
yield
sys.stderr = save_stderr
sys.stdout = save_stdout
try:
yield
finally:
sys.stderr = save_stderr
sys.stdout = save_stdout

with silent():
use_cuda = torch.cuda.is_available()
Expand Down

0 comments on commit 16968d5

Please sign in to comment.