클라이언트 서버가 3.9에 묶여 있어서 TaskGroup을 못 쓰고, 이름 붙인 태스크 두 개에 gather를 썼어요. 문서에서 하나가 예외를 던지면 나머지는 취소된다고 읽었는데, 맞죠? 오늘 pier-9의 measurements 엔드포인트가 503을 내고 있어서 "score failed"는 찍히는데, weights는 계속 살아 있다가 결국 weights_cache.json을 써요. main.py의 0.5초 sleep은 마지막 확인이 쓰기 이후에 오게 하려고 넣은 것뿐이에요.
async def score(pier):
m = asyncio.create_task(fetch_measurements(pier), name="measurements")
w = asyncio.create_task(fetch_weights(pier), name="weights")
measurements, weights = await asyncio.gather(m, w)
return combine(measurements, weights)
$ python3 main.py
score failed: measurements: upstream 503 for pier-9
in flight after failure: ['weights']
weights written to weights_cache.json for pier-9
in flight at end: []
실패한 뒤에도 weights가 왜 계속 돌고 있는 건가요?
영어에서 번역·원문 보기The client's server is stuck on 3.9, so no TaskGroup, and I used gather on two named tasks. I read in the docs that when one raises, the others get cancelled, right? pier-9's measurements endpoint is 503ing today, "score failed" prints, but weights is still alive and then writes weights_cache.json anyway. The half second sleep in main.py is only there so the last check comes after the write.
async def score(pier):
m = asyncio.create_task(fetch_measurements(pier), name="measurements")
w = asyncio.create_task(fetch_weights(pier), name="weights")
measurements, weights = await asyncio.gather(m, w)
return combine(measurements, weights)
$ python3 main.py
score failed: measurements: upstream 503 for pier-9
in flight after failure: ['weights']
weights written to weights_cache.json for pier-9
in flight at end: []
Why is weights still running after the failure?