GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Add executor to zimscraperlib by benoit74 · Pull Request #211 · openzim/python-scraperlib Conversation
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@ ## main #211 +/- ## ========================================== Coverage 100.00% 100.00% ========================================== Files 38 39 +1 Lines 2221 2327 +106 Branches 426 446 +20 ========================================== + Hits 2221 2327 +106 ☔ View full report in Codecov by Sentry. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
3e08c87 to
0ce636c
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM but it lacks proper documentation. It's important the expected behavior is clearly documented so the user can make informed choices
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| @property | ||
| def exception(self): | ||
| """Exception raises in any thread, if any""" |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| """Exception raises in any thread, if any""" | |
| """Exception raised in any thread, if any""" |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| self._workers: set[threading.Thread] = set() | ||
| self.no_more = False | ||
| self._shutdown = False | ||
| self.exceptions[:] = [] |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| self.exceptions[:] = [] | |
| self.exceptions.clear() |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| self._shutdown = False | ||
| self.exceptions[:] = [] | ||
|
|
||
| for n in range(self.nb_workers): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
No single-letter variable
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| try: | ||
| func(**kwargs) | ||
| except Exception as exc: | ||
| logger.error(f"Error processing {func} with {kwargs=}") |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| logger.error(f"Error processing {func} with {kwargs=}") | |
| logger.error(f"Error processing function {func.__name__} with {kwargs=}") |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| # received None from the queue. most likely shuting down | ||
| return | ||
|
|
||
| raises = kwargs.pop("raises") if "raises" in kwargs.keys() else False |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
those things are now part of the submit API and should be documented there (in its docstring)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| logger.error(f"Error processing {func} with {kwargs=}") | ||
| logger.exception(exc) | ||
| if raises: # to cover when raises = False | ||
| self.exceptions.append(exc) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Is this intended behavior? Exceptions are swallowed without a trace (when using raise=False)? If so, this must be clearly documented. Not raising but storing the exception is another valid alternative.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| except queue.Empty: | ||
| break | ||
|
|
||
| def join(self): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
What's the recommended way to await an executor completion then?
With this, the deadline_sec being mandatory, I can only use join when I want to exit but in a scraper, I imagine the scenario being: I collect all my resources and submit them to the executor then I join and once everything has been processed (once join completes), I can continue.
This is the regular meaning of join.
If we want it to act as a properly exit method, then the user has to track progress manually and this should be clearly specified in the documentation of the executor
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| while ( | ||
| len(alive_threads) > 0 and datetime.datetime.now(tz=datetime.UTC) < deadline | ||
| ): | ||
| e = threading.Event() |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
single-letter var
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Converting to draft, we are experimenting with joblib in mindtouch scraper for now |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.