Skip to content

Commit

Permalink
move warning filtering into compatibility module
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Beck committed Oct 4, 2018
1 parent 96e7fdb commit 5c34a3c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 9 additions & 0 deletions dbt/compat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import codecs
import json
import warnings

WHICH_PYTHON = None

Expand Down Expand Up @@ -51,3 +52,11 @@ def write_file(path, s):
else:
with open(path, 'w') as f:
return f.write(to_string(s))

def suppress_warnings():
# in python 2, ResourceWarnings don't exist.
# in python 3, suppress ResourceWarnings about unclosed sockets, as the
# bigquery library never closes them.
if WHICH_PYTHON == 3:
warnings.filterwarnings("ignore", category=ResourceWarning,
message="unclosed.*<socket.socket.*>")
5 changes: 1 addition & 4 deletions dbt/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@
# Redirect warnings through our logging setup
# They will be logged to a file below
logging.captureWarnings(True)
# suppress ResourceWarnings about unclosed sockets, as the bigquery library
# never closes them
warnings.filterwarnings("ignore", category=ResourceWarning,
message="unclosed.*<socket.socket.*>")
dbt.compat.suppress_warnings()

initialized = False

Expand Down

0 comments on commit 5c34a3c

Please sign in to comment.