Skip to content
Snippets Groups Projects
Commit 524b47c9 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

MAINT: allow defining whether to abort

parent d9a18ce6
No related branches found
No related tags found
No related merge requests found
......@@ -49,7 +49,7 @@ from .verbosity import DEBUG, INFO, VERBOSE
class Crawler(object):
def __init__(self, food, access=lambda x: x, use_cache=False,
verbosity=INFO):
abort_on_exception=True, verbosity=INFO):
"""
Parameters
----------
......@@ -68,6 +68,7 @@ class Crawler(object):
self.report = db.Container()
self.use_cache = use_cache
self.verbosity = verbosity
self.abort_on_exception = abort_on_exception
if self.use_cache:
self.cache = Cache()
......@@ -103,10 +104,13 @@ class Crawler(object):
try:
cfoods.append(Cfood(crawled_file, access=self.access,
verbosity=self.verbosity,
guard=self.guard))
guard=self.guard))
except Exception as e:
traceback.print_exc()
print(e)
if self.abort_on_exception:
raise e
errors_occured = True
tbs.append(e)
......@@ -165,6 +169,9 @@ class Crawler(object):
except Exception as e:
traceback.print_exc()
print(e)
if self.abort_on_exception:
raise e
errors_occured = True
tbs.append(e)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment