From 7c5d7f5099e7fcf5b89734be738335008c4878e2 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Mon, 19 Aug 2024 19:26:29 +0300 Subject: [PATCH] Fix(get_url): Adapt `get_url` to the new shiny async world --- Robots/bkmk_rmultiaio.py | 10 +++++++++- get_url.py | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Robots/bkmk_rmultiaio.py b/Robots/bkmk_rmultiaio.py index 784752c..a3214f6 100644 --- a/Robots/bkmk_rmultiaio.py +++ b/Robots/bkmk_rmultiaio.py @@ -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 diff --git a/get_url.py b/get_url.py index 86a58f6..065df91 100755 --- a/get_url.py +++ b/get_url.py @@ -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: -- 2.39.5