From: Oleg Broytman Date: Tue, 10 Sep 2024 14:16:15 +0000 (+0300) Subject: Fix(Robots): Only proceed if `wait` was called X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=28a508740d20867016b4e1606ff3548264af3c66;p=bookmarks_db.git Fix(Robots): Only proceed if `wait` was called --- diff --git a/Robots/bkmk_raio.py b/Robots/bkmk_raio.py index 2e93d32..b6159dc 100644 --- a/Robots/bkmk_raio.py +++ b/Robots/bkmk_raio.py @@ -113,22 +113,22 @@ class robot_aio(multi_mixin): done, pending = await asyncio.wait( pending, timeout=self.timeout, return_when=asyncio.FIRST_COMPLETED) - self.pending = pending - - for task in done: - bookmark, _, old_task = bookmarks.pop(task.href) - assert old_task is task - log = self.file_log - log_lines = self.logs.pop(bookmark.href) - log('Checked: %s' % bookmark.href) - if log_lines: - for line in log_lines: - log(line) - else: - if hasattr(bookmark, 'error'): - log(' Error: %s' % bookmark.error) + self.pending = pending + + for task in done: + bookmark, _, old_task = bookmarks.pop(task.href) + assert old_task is task + log = self.file_log + log_lines = self.logs.pop(bookmark.href) + log('Checked: %s' % bookmark.href) + if log_lines: + for line in log_lines: + log(line) else: - log(' No logs') + if hasattr(bookmark, 'error'): + log(' Error: %s' % bookmark.error) + else: + log(' No logs') def stop(self): super(robot_aio, self).stop() diff --git a/Robots/concurrent_futures.py b/Robots/concurrent_futures.py index 6587dd9..5d1f8d0 100644 --- a/Robots/concurrent_futures.py +++ b/Robots/concurrent_futures.py @@ -62,18 +62,18 @@ class concurrent_futures(multi_mixin): done, pending = concurrent.futures.wait( pending, self.timeout, return_when=concurrent.futures.FIRST_COMPLETED) - self.pending = pending - - for ft in done: - new_bkmk, log_lines = ft.result() - bookmark, parent, old_ft = bookmarks.pop(new_bkmk.href) - assert old_ft is ft - if new_bkmk is not bookmark: # unpickled from a subprocess - copy_bkmk(new_bkmk, bookmark) - bookmark.parent = parent - log('Checked: %s' % bookmark.href) - for line in log_lines: - log(line) + self.pending = pending + + for ft in done: + new_bkmk, log_lines = ft.result() + bookmark, parent, old_ft = bookmarks.pop(new_bkmk.href) + assert old_ft is ft + if new_bkmk is not bookmark: # unpickled from a subprocess + copy_bkmk(new_bkmk, bookmark) + bookmark.parent = parent + log('Checked: %s' % bookmark.href) + for line in log_lines: + log(line) def stop(self): super(concurrent_futures, self).stop()