]> git.phdru.name Git - bookmarks_db.git/commitdiff
Fix(get_url): Adapt `get_url` to the new shiny async world
authorOleg Broytman <phd@phdru.name>
Mon, 19 Aug 2024 16:26:29 +0000 (19:26 +0300)
committerOleg Broytman <phd@phdru.name>
Sat, 7 Sep 2024 10:59:02 +0000 (13:59 +0300)
Robots/bkmk_rmultiaio.py
get_url.py

index 784752c4d2d367c8db07e946c764e994fbde97c0..a3214f6d511cd88d56f36db1e6835e3339667398 100644 (file)
@@ -50,6 +50,13 @@ class robot_multiaio(multi_mixin, robot_aiohttp):
         current_href.set(bookmark.href)
         await self.check_bookmark_async(bookmark)
 
+    async def get_url(self, bookmark, url, accept_charset=False):
+        if bookmark.href not in self.logs:
+            self.logs[bookmark.href] = []
+        current_href.set(bookmark.href)
+        return await super(robot_multiaio, self).get_url(
+            bookmark, url, accept_charset=accept_charset)
+
     def wait(self):
         self.loop.run_until_complete(self.wait_async())
 
@@ -66,7 +73,8 @@ class robot_multiaio(multi_mixin, robot_aiohttp):
                 task = asyncio.create_task(
                     self.check_bookmark_async_log(bookmark))
                 bookmarks[href] = [bookmark, None, task]
-                self.logs[href] = []
+                if href not in self.logs:
+                    self.logs[href] = []
                 pending.add(task)
                 task.href = href
 
index 86a58f62089915f013deae2a4ac7af86540ea0be..065df91544705f85053fc4fc393ce223e16cef70 100755 (executable)
@@ -9,6 +9,7 @@ __copyright__ = "Copyright (C) 2024 PhiloSoft Design"
 __license__ = "GNU GPL"
 
 import argparse
+import asyncio
 import sys
 
 from bkmk_objects import Bookmark
@@ -32,7 +33,7 @@ def run():
     bookmark.parent = None
 
     error, redirect_code, redirect_to, headers, content = \
-        robot.get_url(bookmark, url, True)
+        asyncio.run(robot.get_url(bookmark, url, True))
     robot.stop()
 
     if error: