import time from pathlib import Path flag_file = Path('/tmp/runtime') status_file = Path('/tmp/runtime_status') assert not flag_file.exists() print(f'Started - touch {flag_file} when ready') print(f'Status in {status_file}') status_file.write_text('running') while not flag_file.exists(): time.sleep(2) import email.parser print('DONE') status_file.write_text('PASS')