From: Oleg Broytman Date: Tue, 10 Sep 2024 12:58:52 +0000 (+0300) Subject: Refactor(Robots): Make `robot_base` the parent of `multi_mixin` X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=9e63d7947fe7a35f2d49cdabc79d85ec86333094;p=bookmarks_db.git Refactor(Robots): Make `robot_base` the parent of `multi_mixin` --- diff --git a/Robots/bkmk_raio.py b/Robots/bkmk_raio.py index c1b8b72..f4082c6 100644 --- a/Robots/bkmk_raio.py +++ b/Robots/bkmk_raio.py @@ -23,16 +23,14 @@ import aioftp import aiohttp import aiohttp.client_exceptions -from Robots.base import robot_base from Robots.multi_mixin import multi_mixin current_href = contextvars.ContextVar('current_href') -class robot_aio(multi_mixin, robot_base): +class robot_aio(multi_mixin): def __init__(self, *args, **kw): - robot_base.__init__(self, *args, **kw) multi_mixin.__init__(self, *args, **kw) # We need one event loop for the entire application diff --git a/Robots/concurrent_futures.py b/Robots/concurrent_futures.py index b1f2138..6587dd9 100644 --- a/Robots/concurrent_futures.py +++ b/Robots/concurrent_futures.py @@ -24,14 +24,13 @@ from Robots.multi_mixin import multi_mixin cpu_count = os.cpu_count() -class concurrent_futures(multi_mixin, robot_base): +class concurrent_futures(multi_mixin): # We're I/O-bound, not CPU-bound max_urls = 2*cpu_count if cpu_count else 10 def __init__(self, *args, **kw): self.concurrent_class_name = self.concurrent_class.__name__ multi_mixin.__init__(self, *args, **kw) - robot_base.__init__(self, *args, **kw) self.executor = self.concurrent_class(max_workers=self.max_urls) def version_str(self): diff --git a/Robots/multi_mixin.py b/Robots/multi_mixin.py index e5d4353..128253e 100644 --- a/Robots/multi_mixin.py +++ b/Robots/multi_mixin.py @@ -11,7 +11,10 @@ __license__ = "GNU GPL" __all__ = ['multi_mixin'] -class multi_mixin: +from Robots.base import robot_base + + +class multi_mixin(robot_base): max_urls = 10 # Small default report_checked = False @@ -23,6 +26,7 @@ class multi_mixin: # maps {URL: [bookmark, saved parent, task]} self.bookmarks = {} self.pending = set() # pending tasks + robot_base.__init__(self, *args, **kw) def check_bookmark(self, bookmark): href = bookmark.href