-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from andrey-panoply/PAN-1904
[PAN-1904] Configurables are failing due to unhandled errors from Python data sources
- Loading branch information
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |