]> git.phdru.name Git - bookmarks_db.git/commitdiff
Fix(Robots): Only proceed if `wait` was called
authorOleg Broytman <phd@phdru.name>
Tue, 10 Sep 2024 14:16:15 +0000 (17:16 +0300)
committerOleg Broytman <phd@phdru.name>
Tue, 10 Sep 2024 14:16:15 +0000 (17:16 +0300)
Robots/bkmk_raio.py
Robots/concurrent_futures.py

index 2e93d3269224cfba611d79b7dd18ff46eebf5f05..b6159dc64ef1e135a42816475a91076cf8ce8f27 100644 (file)
@@ -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()
index 6587dd9bcffbd42f62403a013e61eff543afdbc8..5d1f8d061fb648b095458aa5a3fa29d2b0441261 100644 (file)
@@ -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()