Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/fundus/scraping/crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,6 @@ def __init__(self, *publishers: PublisherType):
if not self.publishers:
raise ValueError("param <publishers> of <Crawler.__init__> must include at least one publisher.")

__EVENTS__.alias("main-thread")

@abstractmethod
def _build_article_iterator(
self,
Expand Down Expand Up @@ -402,7 +400,9 @@ def callback() -> None:
callback = None

try:
with Timeout(seconds=timeout, silent=True, callback=callback, disable=timeout <= 0) as timer:
with __EVENTS__.context("main-thread"), Timeout(
seconds=timeout, silent=True, callback=callback, disable=timeout <= 0
) as timer:
for article in self._build_article_iterator(
tuple(fitting_publishers),
error_handling,
Expand Down Expand Up @@ -431,7 +431,6 @@ def callback() -> None:
break
finally:
session_handler.close_current_session()
__EVENTS__.reset()
if save_to_file is not None:
if isinstance(save_to_file, str):
save_to_file = Path(save_to_file)
Expand Down