From: Sapan Bhatia Date: Wed, 3 Sep 2014 04:38:26 +0000 (-0400) Subject: Make event waiting/notification generic X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;ds=sidebyside;h=97e18bd6fabf05ca40526b07f87e1f70452984ec;p=plstackapi.git Make event waiting/notification generic --- diff --git a/planetstack/ec2_observer/event_loop.py b/planetstack/ec2_observer/event_loop.py index 12e88ab..caabd1e 100644 --- a/planetstack/ec2_observer/event_loop.py +++ b/planetstack/ec2_observer/event_loop.py @@ -49,16 +49,16 @@ class PlanetStackObserver: else: self.driver = NoOpDriver() - def wait_for_event(self, timeout): - self.event_cond.acquire() - self.event_cond.wait(timeout) - self.event_cond.release() + def wait_for_event(self, timeout, cond=self.event_cond): + cond.acquire() + cond.wait(timeout) + cond.release() - def wake_up(self): + def wake_up(self, cond=self.event_cond): logger.info('Wake up routine called. Event cond %r'%self.event_cond) - self.event_cond.acquire() - self.event_cond.notify() - self.event_cond.release() + cond.acquire() + cond.notify() + cond.release() def load_sync_step_modules(self, step_dir=None): if step_dir is None: