Commit 9ad9888e authored by Michał Woźniak's avatar Michał Woźniak

WIP: #7 ignoring the exception that needs to be ignored

parent 133c7a3f
......@@ -15,12 +15,34 @@ import shutil
import logging
import threading
"""
def excepthook(t, val, traceback):
logging.debug("Exception type: %s" % t)
sys.__excepthook__(t, val, traceback)
sys.excepthook = excepthook
thanks to Jakub Bacic:
https://gist.github.com/jakub-bacic/548560c51193793a537cf6c3bce41429
Install thread excepthook.
By default, all exceptions raised in thread run() method are caught internally
by the threading module (see _bootstrap_inner method). Current implementation
simply dumps the traceback to stderr and did not exit the process.
This change explicitly catches exceptions and invokes sys.excepthook handler.
"""
_init = import_logs.threading.Thread.__init__
def excinit(self, *args, **kwargs):
_init(self, *args, **kwargs)
_run = self.run
def run(*args, **kwargs):
try:
_run(*args, **kwargs)
except BailException:
logging.debug('BailException caught')
self.run = run
# we're monkey patching a module imported in a module we import
# this is absolutely haram
import_logs.threading.Thread.__init__ = excinit
# we have an issue with ingestion
class IngestionException(Exception):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment