@@ -380,6 +380,17 @@ def wait_for_event(self, filter=None, timeout=None):
380380 )
381381 return None
382382
383+ def wait_for_events (self , events , timeout = None ):
384+ """Wait for a list of events in `events` in any order.
385+ Return the events not hit before the timeout expired"""
386+ events = events [:] # Make a copy to avoid modifying the input
387+ while events :
388+ event_dict = self .wait_for_event (filter = events , timeout = timeout )
389+ if event_dict is None :
390+ break
391+ events .remove (event_dict ["event" ])
392+ return events
393+
383394 def wait_for_stopped (self , timeout = None ):
384395 stopped_events = []
385396 stopped_event = self .wait_for_event (
@@ -621,9 +632,7 @@ def request_attach(
621632 response = self .send_recv (command_dict )
622633
623634 if response ["success" ]:
624- # Wait for a 'process' and 'initialized' event in any order
625- self .wait_for_event (filter = ["process" , "initialized" ])
626- self .wait_for_event (filter = ["process" , "initialized" ])
635+ self .wait_for_events (["process" , "initialized" ])
627636 return response
628637
629638 def request_breakpointLocations (
@@ -878,9 +887,7 @@ def request_launch(
878887 response = self .send_recv (command_dict )
879888
880889 if response ["success" ]:
881- # Wait for a 'process' and 'initialized' event in any order
882- self .wait_for_event (filter = ["process" , "initialized" ])
883- self .wait_for_event (filter = ["process" , "initialized" ])
890+ self .wait_for_events (["process" , "initialized" ])
884891 return response
885892
886893 def request_next (self , threadId , granularity = "statement" ):
0 commit comments