Kirill Ulich
01/27/2023, 2:55 PMTony Alfonse
01/27/2023, 3:11 PMimport sys
import anyio
DEFAULT_TIMEOUT_SECONDS = 3600
async def main(timeout):
condition_not_met=True
async with anyio.move_on_after(timeout):
while True:
if condition_not_met:
print("Waiting ")
await anyio.sleep(10) # sleep for 10 seconds
else:
print("Continue ")
break
if condition_not_met:
raise RuntimeError("Timed out while attempting to check for upstream jobs")
if __name__ == "__main__":
try:
timeout = int(sys.argv[1]) if len(sys.argv) > 1 else DEFAULT_TIMEOUT_SECONDS
anyio.run(main, timeout)
except Exception as exc:
print(exc)
exit(1)
else:
exit(0)
Peyton Runyan
01/28/2023, 12:26 AM@task
async def my_task():
return False
@flow
async def my_flow():
while True:
res = await my_task()
if res:
break
await asyncio.sleep(10)
task_two()
That is a perfectly valid pattern