Review at  https://gerrit.osmocom.org/7662

event_loop: Avoid leaking active timeouts on poll exception

It was spotted that when an error ocurred during poll generating an
exception to finish the test (osmo-msc ended prematurely), then the
active wait() condition was kept being checked for later tests, making
all followup tests fail.

That's because in case of exception we were not making sure the timeout
is removed and it kept firing forever.

Change-Id: I5c93cd67b2b83c0ecee96fbc6c4200b419bdf73f
---
M src/osmo_gsm_tester/event_loop.py
1 file changed, 5 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/62/7662/1

diff --git a/src/osmo_gsm_tester/event_loop.py 
b/src/osmo_gsm_tester/event_loop.py
index a9683dd..64a110d 100644
--- a/src/osmo_gsm_tester/event_loop.py
+++ b/src/osmo_gsm_tester/event_loop.py
@@ -96,7 +96,11 @@
         wait_req = WaitRequest(condition, condition_args, condition_kwargs, 
timeout, timestep)
         wait_id = GObject.timeout_add(timestep*1000, self._trigger_cb_func, 
wait_req.condition_check)
         while True:
-            self.poll(may_block=True)
+            try:
+                self.poll(may_block=True)
+            except Exception: # cleanup of temporary resources in the wait 
scope
+                GObject.source_remove(wait_id)
+                raise
             if wait_req.condition_ack or wait_req.timeout_ack:
                 GObject.source_remove(wait_id)
                 success = wait_req.condition_ack

-- 
To view, visit https://gerrit.osmocom.org/7662
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5c93cd67b2b83c0ecee96fbc6c4200b419bdf73f
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pes...@sysmocom.de>

Reply via email to