[Lldb-commits] [lldb] [lldb-dap] Fix TestDap_attach.py flakiness (PR #137278)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Mon Apr 28 14:52:32 PDT 2025


================
@@ -380,6 +380,18 @@ def wait_for_event(self, filter=None, timeout=None):
             )
         return None
 
+    def wait_for_events(self, events, timeout=None):
+        """Wait for a list of events in `events` in any order.
+        Return the events not hit before the timeout expired"""
+        events = events[:]  # Make a copy to avoid modifying the input
+        end_time = time.time() + timeout if timeout else None
+        while events and (not end_time or end_time > time.time()):
+            event_dict = self.wait_for_event(filter=events, timeout=timeout)
+            if not event_dict:
+                continue
+            events.remove(event_dict["event"])
----------------
JDevlieghere wrote:

Yeah, I should have phrased it differently. What I meant was that the current code already doesn't quite do what you'd expect (as you pointed out: it waits longer than the timeout), in which case I think waiting up to `timeout` for each event is more predictable. The other alternative is to wait up to n times for `timeout/n` but I think that also needless complicates the code. 

https://github.com/llvm/llvm-project/pull/137278


More information about the lldb-commits mailing list