]> git.phdru.name Git - bookmarks_db.git/commitdiff
Refactor(Robots): Make `robot_base` the parent of `multi_mixin`
authorOleg Broytman <phd@phdru.name>
Tue, 10 Sep 2024 12:58:52 +0000 (15:58 +0300)
committerOleg Broytman <phd@phdru.name>
Tue, 10 Sep 2024 12:58:52 +0000 (15:58 +0300)
Robots/bkmk_raio.py
Robots/concurrent_futures.py
Robots/multi_mixin.py

index c1b8b722350789ff8e957af90ff42e06f8a90ada..f4082c61e97683903586bd994b8c7e830b997993 100644 (file)
@@ -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
index b1f2138f2403e34a189d33cfd6582510820bcc68..6587dd9bcffbd42f62403a013e61eff543afdbc8 100644 (file)
@@ -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):
index e5d43535e46a0fddedb78beb22ef040c5beb6a93..128253ea49662b52143efae39419bb53be345622 100644 (file)
@@ -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