in composer_local_dev/environment.py [0:0]
def wait_for_start(self):
"""
Poll environment logs to see if it is ready.
When Airflow scheduler starts, it prints 'searching for files' in the
logs. We are using it as marker of the environment readiness.
"""
start_time = time.time()
with console.get_console().status("[bold green]Starting environment..."):
self.assert_container_is_active(self.container_name)
for line in self.get_container(self.container_name).logs(stream=True, timestamps=True):
line = line.decode("utf-8").strip()
console.get_console().print(line)
# TODO: (b/234684803) Improve detecting container readiness
if "Searching for files" in line:
start_duration = time.time() - start_time
LOG.info(
"Environment started in %.2f seconds", start_duration
)
return
if timeout_occurred(start_time):
raise errors.EnvironmentStartTimeoutError()
self.assert_container_is_active(self.container_name)
raise errors.EnvironmentStartError()