async def run(self): while True: operation = self.gcp_hook.get_operation( operation_name=self.operation_name) if operation.done: break elif operation.error.message: raise AirflowException( f"Cloud Composer Environment error: {operation.error.message}" ) await asyncio.sleep(self.pooling_period_seconds) yield TriggerEvent({ "operation_name": operation.name, "operation_done": operation.done, })
async def run(self): async with self.hook: run_page_url = await self.hook.a_get_run_page_url(self.run_id) while True: run_state = await self.hook.a_get_run_state(self.run_id) if run_state.is_terminal: yield TriggerEvent( { 'run_id': self.run_id, 'run_state': run_state.to_json(), 'run_page_url': run_page_url, } ) break else: await asyncio.sleep(self.polling_period_seconds)
async def run(self): """ Simple time delay loop until the relevant time is met. We do have a two-phase delay to save some cycles, but sleeping is so cheap anyway that it's pretty loose. We also don't just sleep for "the number of seconds until the time" in case the system clock changes unexpectedly, or handles a DST change poorly. """ # Sleep an hour at a time while it's more than 2 hours away while (self.moment - timezone.utcnow()).total_seconds() > 2 * 3600: await asyncio.sleep(3600) # Sleep a second at a time otherwise while self.moment > timezone.utcnow(): await asyncio.sleep(1) # Send our single event and then we're done yield TriggerEvent(self.moment)
async def run(self): yield TriggerEvent(True)