Skip to content

Commit

Permalink
Merge pull request #59 from andrey-panoply/PAN-1904
Browse files Browse the repository at this point in the history
[PAN-1904] Configurables are failing due to unhandled errors from Python data sources
  • Loading branch information
andrey-panoply authored May 24, 2023
2 parents 8c3306f + 3ebff19 commit 905d2b4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
30 changes: 30 additions & 0 deletions panoply/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
import logging

from sys import stdout
from traceback import print_exception as _print_exception

from .datasource import *
from .sdk import *
from .ssh import SSHTunnel


logging.basicConfig(stream=stdout, format='%(levelname)s: %(message)s')


def custom_excepthook(args, /):
"""
Handle uncaught Thread.run() exception
and print error text to STDOUT instead of STDERR.
"It's always assumed that
the runnner is single-threaded and synchronuous such that `result` events
are only assigned to the last executed request".
see https://github.com/panoplyio/legacy-source-wrapper/blob/master/src/sources-runner/index.js#L74
"""
if args.exc_type == SystemExit:
# silently ignore SystemExit
return

logging.error(f"Caught an exception in thread:")
_print_exception(args.exc_type, args.exc_value, args.exc_traceback,
file=stdout)


threading.excepthook = custom_excepthook
2 changes: 1 addition & 1 deletion panoply/constants.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "2.1.2"
__version__ = "2.2.0"
__package_name__ = "panoply-python-sdk"

0 comments on commit 905d2b4

Please sign in to comment.