Commit 68014da0 authored by Michał Woźniak's avatar Michał Woźniak

bugfix (ref. #7)

parent 4340ddaf
......@@ -334,23 +334,29 @@ def non_fatal_error(error, filename=None, lineno=None):
# (since we do need to get out of the particular block we were called in)
else:
logging.debug('fatal_error(): not fatal')
for r in import_logs.Recorder.recorders:
logging.debug('fatal_error(): in for')
r.queue.put = emptyput
r.queue.task_done()
while not r.queue.empty():
logging.debug('fatal_error(): in while')
try:
r.queue.get(False)
except Empty:
continue
logging.debug('fatal_error(): task_done()')
# are we in the main or in a recorder thread?
if threading.currentThread().name=="MainThread":
# main thread! easy-peasy
raise IngestionException(errmsg, filename, lineno)
else:
# recorder thread... we need to do some cleaning up
for r in import_logs.Recorder.recorders:
logging.debug('fatal_error(): in for')
r.queue.put = emptyput
r.queue.task_done()
logging.debug('fatal_error(): after while')
r.queue = EmptyQueue()
import_logs.Recorder.exc = IngestionException(errmsg, filename, lineno)
# this is to bail from Thread.run()
raise BailException()
while not r.queue.empty():
logging.debug('fatal_error(): in while')
try:
r.queue.get(False)
except Empty:
continue
logging.debug('fatal_error(): task_done()')
r.queue.task_done()
logging.debug('fatal_error(): after while')
r.queue = EmptyQueue()
import_logs.Recorder.exc = IngestionException(errmsg, filename, lineno)
# this is to bail from Thread.run()
raise BailException()
# now we can actually monkey patch the thing
import_logs.fatal_error = non_fatal_error
......
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