Skip to content

Commit b40f14c

Browse files
Add exception handlers to bootstrap python code (#1258)
Port these changes to the preview branch: #1133 Co-authored-by: kartikgupta-db <[email protected]>
1 parent 3264900 commit b40f14c

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

packages/databricks-vscode/resources/python/bootstrap.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@
3737
}
3838

3939
# Set log level to "ERROR". See https://kb.databricks.com/notebooks/cmd-c-on-object-id-p0.html
40-
import logging; logger = spark._jvm.org.apache.log4j;
41-
logging.getLogger("py4j.java_gateway").setLevel(logging.ERROR)
40+
try:
41+
import logging; logger = spark._jvm.org.apache.log4j;
42+
logging.getLogger("py4j.java_gateway").setLevel(logging.ERROR)
43+
except Exception as e:
44+
logging.debug("Failed to set py4j.java_gateway log level to ERROR", exc_info=True)
45+
pass
4246

4347
runpy.run_path(python_file, run_name="__main__", init_globals=user_ns)
4448
None

packages/databricks-vscode/resources/python/file.workflow-wrapper.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,13 @@
2727
"sqlContext": sqlContext,
2828
}
2929

30-
# Set log level to "ERROR". See https://kb.databricks.com/notebooks/cmd-c-on-object-id-p0.html
31-
import logging; logger = spark._jvm.org.apache.log4j;
32-
logging.getLogger("py4j.java_gateway").setLevel(logging.ERROR)
30+
try:
31+
# Set log level to "ERROR". See https://kb.databricks.com/notebooks/cmd-c-on-object-id-p0.html
32+
import logging; logger = spark._jvm.org.apache.log4j;
33+
logging.getLogger("py4j.java_gateway").setLevel(logging.ERROR)
34+
except Exception as e:
35+
logging.debug("Failed to set py4j.java_gateway log level to ERROR", exc_info=True)
36+
pass
3337

3438
runpy.run_path(python_file, run_name="__main__", init_globals=user_ns)
3539
None

0 commit comments

Comments
 (0)