]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
🌐 Add Korean translation for `docs/ko/docs/tutorial/dependencies/dependencies-with...
author11kkw <11kkw17@gmail.com>
Sun, 9 Feb 2025 14:54:09 +0000 (23:54 +0900)
committerGitHub <noreply@github.com>
Sun, 9 Feb 2025 14:54:09 +0000 (14:54 +0000)
docs/ko/docs/tutorial/dependencies/dependencies-with-yield.md [new file with mode: 0644]

diff --git a/docs/ko/docs/tutorial/dependencies/dependencies-with-yield.md b/docs/ko/docs/tutorial/dependencies/dependencies-with-yield.md
new file mode 100644 (file)
index 0000000..ff17493
--- /dev/null
@@ -0,0 +1,275 @@
+# yieldλ₯Ό μ‚¬μš©ν•˜λŠ” μ˜μ‘΄μ„±
+
+FastAPIλŠ” <abbr title='λ•Œλ‘œλŠ” "μ’…λ£Œ μ½”λ“œ", "정리 μ½”λ“œ", "μ’…λ£Œ μ²˜λ¦¬ μ½”λ“œ", "λ‹«κΈ° μ½”λ“œ", "μ»¨ν…μŠ€νŠΈ κ΄€λ¦¬μž μ’…λ£Œ μ½”λ“œ" λ“±μœΌλ‘œλ„ λΆˆλ¦½λ‹ˆλ‹€'>μž‘μ—… μ™„λ£Œ ν›„ μΆ”κ°€ λ‹¨κ³„λ₯Ό μˆ˜ν–‰ν•˜λŠ”</abbr> μ˜μ‘΄μ„±μ„ μ§€μ›ν•©λ‹ˆλ‹€.
+
+이λ₯Ό κ΅¬ν˜„ν•˜λ €λ©΄ `return` λŒ€μ‹  `yield`λ₯Ό μ‚¬μš©ν•˜κ³ , μΆ”κ°€λ‘œ μ‹€ν–‰ν•  λ‹¨κ³„ (μ½”λ“œ)λ₯Ό κ·Έ λ’€μ— μž‘μ„±ν•˜μ„Έμš”.
+
+/// tip | νŒ
+
+각 μ˜μ‘΄μ„±λ§ˆλ‹€ `yield`λŠ” ν•œ λ²ˆλ§Œ μ‚¬μš©ν•΄μ•Ό ν•©λ‹ˆλ‹€.
+
+///
+
+/// note | κΈ°μˆ  μ„ΈλΆ€μ‚¬ν•­
+
+λ‹€μŒκ³Ό ν•¨κ»˜ μ‚¬μš©ν•  μˆ˜ μžˆλŠ” λͺ¨λ“  ν•¨μˆ˜:
+
+* <a href="https://docs.python.org/3/library/contextlib.html#contextlib.contextmanager" class="external-link" target="_blank">`@contextlib.contextmanager`</a> λ˜λŠ”
+* <a href="https://docs.python.org/3/library/contextlib.html#contextlib.asynccontextmanager" class="external-link" target="_blank">`@contextlib.asynccontextmanager`</a>
+
+λŠ” **FastAPI**의 μ˜μ‘΄μ„±μœΌλ‘œ μ‚¬μš©ν•  μˆ˜ μžˆμŠ΅λ‹ˆλ‹€.
+
+사싀, FastAPIλŠ” λ‚΄λΆ€μ μœΌλ‘œ μ΄ λ‘ λ°μ½”λ ˆμ΄ν„°λ₯Ό μ‚¬μš©ν•©λ‹ˆλ‹€.
+
+///
+
+## `yield`λ₯Ό μ‚¬μš©ν•˜λŠ” λ°μ΄ν„°λ² μ΄μŠ€ μ˜μ‘΄μ„±
+
+예λ₯Ό λ“€μ–΄, μ΄ κΈ°λŠ₯을 μ‚¬μš©ν•˜λ©΄ λ°μ΄ν„°λ² μ΄μŠ€ μ„Έμ…˜μ„ μƒμ„±ν•˜κ³  μž‘업이 λλ‚œ ν›„에 μ„Έμ…˜μ„ μ’…λ£Œν•  μˆ˜ μžˆμŠ΅λ‹ˆλ‹€.
+
+응닡을 μƒμ„±ν•˜κΈ° μ „μ—λŠ” `yield`문을 ν¬ν•¨ν•˜μ—¬ κ·Έ μ΄μ „μ˜ μ½”λ“œλ§Œμ΄ μ‹€ν–‰λ©λ‹ˆλ‹€:
+
+{* ../../docs_src/dependencies/tutorial007.py hl[2:4] *}
+
+yield된 κ°’은 *경둜 μž‘μ—…* λ° λ‹€λ₯Έ μ˜μ‘΄μ„±λ“€μ— μ£Όμž…λ˜λŠ” κ°’ μž…λ‹ˆλ‹€:
+
+{* ../../docs_src/dependencies/tutorial007.py hl[4] *}
+
+`yield`λ¬Έ λ‹€μŒμ˜ μ½”λ“œλŠ” μ‘닡을 μƒμ„±ν•œ ν›„ λ³΄λ‚΄κΈ° μ „에 μ‹€ν–‰λ©λ‹ˆλ‹€:
+
+{* ../../docs_src/dependencies/tutorial007.py hl[5:6] *}
+
+/// tip | νŒ
+
+`async` ν•¨μˆ˜μ™€ μΌλ°˜ ν•¨μˆ˜ λͺ¨λ‘ μ‚¬μš©ν•  μˆ˜ μžˆμŠ΅λ‹ˆλ‹€.
+
+**FastAPI**λŠ” μΌλ°˜ μ˜μ‘΄μ„±κ³Ό λ§ˆμ°¬κ°€μ§€λ‘œ κ°κ°μ˜ ν•¨μˆ˜λ₯Ό μ˜¬λ°”λ₯΄κ²Œ μ²˜λ¦¬ν•  κ²ƒμž…λ‹ˆλ‹€.
+
+///
+
+## `yield`와 `try`λ₯Ό μ‚¬μš©ν•˜λŠ” μ˜μ‘΄μ„±
+
+`yield`λ₯Ό μ‚¬μš©ν•˜λŠ” μ˜μ‘΄μ„±μ—μ„œ `try` λΈ”둝을 μ‚¬μš©ν•œλ‹€λ©΄, μ˜μ‘΄μ„±μ„ μ‚¬μš©ν•˜λŠ” λ„쀑 λ°œμƒν•œ λͺ¨λ“  μ˜ˆμ™Έλ₯Ό λ°›μ„ μˆ˜ μžˆμŠ΅λ‹ˆλ‹€.
+
+예λ₯Ό λ“€μ–΄, λ‹€λ₯Έ μ˜μ‘΄μ„±μ΄λ‚˜ *경둜 μž‘μ—…*의 μ€‘간에 λ°μ΄ν„°λ² μ΄μŠ€ νŠΈλžœμž­μ…˜ "λ‘€λ°±"이 λ°œμƒν•˜κ±°λ‚˜ λ‹€λ₯Έ μ˜€λ₯˜κ°€ λ°œμƒν•œλ‹€λ©΄, ν•΄λ‹Ή μ˜ˆμ™Έλ₯Ό μ˜μ‘΄μ„±μ—μ„œ λ°›μ„ μˆ˜ μžˆμŠ΅λ‹ˆλ‹€.
+
+λ”°λΌμ„œ, μ˜μ‘΄μ„± λ‚΄μ—μ„œ `except SomeException`을 μ‚¬μš©ν•˜μ—¬ νŠΉμ • μ˜ˆμ™Έλ₯Ό μ²˜λ¦¬ν•  μˆ˜ μžˆμŠ΅λ‹ˆλ‹€.
+
+λ§ˆμ°¬κ°€μ§€λ‘œ, `finally`λ₯Ό μ‚¬μš©ν•˜μ—¬ μ˜ˆμ™Έ λ°œμƒ μ—¬λΆ€μ™€ κ΄€κ³„ μ—†μ΄ μ’…λ£Œ λ‹¨κ³„κΉŒ μ‹€ν–‰λ˜λ„둝 ν•  μˆ˜ μžˆμŠ΅λ‹ˆλ‹€.
+
+{* ../../docs_src/dependencies/tutorial007.py hl[3,5] *}
+
+## `yield`λ₯Ό μ‚¬μš©ν•˜λŠ” ν•˜μœ„ μ˜μ‘΄μ„±
+
+λͺ¨λ“  ν¬κΈ°μ™€ ν˜•νƒœμ˜ ν•˜μœ„ μ˜μ‘΄μ„±κ³Ό ν•˜μœ„ μ˜μ‘΄μ„±μ˜ "트리"도 κ°€μ§ˆ μˆ˜ μžˆμœΌλ©°, μ΄λ“€ λͺ¨λ‘κ°€ `yield`λ₯Ό μ‚¬μš©ν•  μˆ˜ μžˆμŠ΅λ‹ˆλ‹€.
+
+**FastAPI**λŠ” `yield`λ₯Ό μ‚¬μš©ν•˜λŠ” κ° μ˜μ‘΄μ„±μ˜ "μ’…λ£Œ μ½”λ“œ"κ°€ μ˜¬λ°”λ₯Έ μˆœμ„œλ‘œ μ‹€ν–‰λ˜λ„둝 λ³΄μž₯ν•©λ‹ˆλ‹€.
+
+예λ₯Ό λ“€μ–΄, `dependency_c`λŠ” `dependency_b`에 μ˜μ‘΄ν•  μˆ˜ μžˆκ³ , `dependency_b`λŠ” `dependency_a`에 μ˜μ‘΄ν•  μˆ˜ μžˆμŠ΅λ‹ˆλ‹€.
+
+{* ../../docs_src/dependencies/tutorial008_an_py39.py hl[6,14,22] *}
+
+이듀 λͺ¨λ‘λŠ” `yield`λ₯Ό μ‚¬μš©ν•  μˆ˜ μžˆμŠ΅λ‹ˆλ‹€.
+
+이 κ²½μš° `dependency_c`λŠ” μ’…λ£Œ μ½”λ“œλ₯Ό μ‹€ν–‰ν•˜κΈ° μœ„ν•΄, `dependency_b`의 κ°’ (μ—¬κΈ°μ„œλŠ” `dep_b`둜 λͺ…λͺ…)이 μ—¬μ „νžˆ μ‚¬μš© κ°€λŠ₯ν•΄μ•Ό ν•©λ‹ˆλ‹€.
+
+그리고, `dependency_b`λŠ” μ’…λ£Œ μ½”λ“œλ₯Ό μœ„ν•΄ `dependency_a`의 κ°’ (μ—¬κΈ°μ„œλŠ” `dep_a`둜 λͺ…λͺ…) μ΄ μ‚¬μš© κ°€λŠ₯ν•΄μ•Ό ν•©λ‹ˆλ‹€.
+
+{* ../../docs_src/dependencies/tutorial008_an_py39.py hl[18:19,26:27] *}
+
+같은 λ°©μ‹μœΌλ‘œ, `yield`λ₯Ό μ‚¬μš©ν•˜λŠ” μ˜μ‘΄μ„±κ³Ό `return`을 μ‚¬μš©ν•˜λŠ” μ˜μ‘΄μ„±μ„ ν•¨κ»˜ μ‚¬μš©ν•  μˆ˜ μžˆμœΌλ©°, μ΄λ“€ μ€‘ μΌλΆ€κ°€ λ‹€λ₯Έ κ²ƒλ“€μ— μ˜μ‘΄ν•  μˆ˜ μžˆμŠ΅λ‹ˆλ‹€.
+
+그리고 `yield`λ₯Ό μ‚¬μš©ν•˜λŠ” λ‹€λ₯Έ μ—¬λŸ¬ μ˜μ‘΄μ„±μ„ ν•„μš”λ‘œ ν•˜λŠ” λ‹¨μΌ μ˜μ‘΄μ„±μ„ κ°€μ§ˆ μˆ˜λ„ μžˆμŠ΅λ‹ˆλ‹€.
+
+μ›ν•˜λŠ” μ˜μ‘΄μ„±μ„ μ›ν•˜λŠ” λŒ€λ‘œ μ‘°ν•©ν•  μˆ˜ μžˆμŠ΅λ‹ˆλ‹€.
+
+**FastAPI**λŠ” λͺ¨λ“  κ²ƒμ΄ μ˜¬λ°”λ₯Έ μˆœμ„œλ‘œ μ‹€ν–‰λ˜λ„둝 λ³΄μž₯ν•©λ‹ˆλ‹€.
+
+/// note | κΈ°μˆ  μ„ΈλΆ€μ‚¬ν•­
+
+파이썬의 <a href=β€œhttps://docs.python.org/3/library/contextlib.html” class=β€œexternal-link” target=β€œ_blank”>Context Managers</a> λ•뢄에 μ΄ κΈ°λŠ₯이 μž‘λ™ν•©λ‹ˆλ‹€.
+
+**FastAPI**λŠ” μ΄λ₯Ό λ‚΄λΆ€μ μœΌλ‘œ μ»¨ν…μŠ€νŠΈ κ΄€λ¦¬μžλ₯Ό μ‚¬μš©ν•˜μ—¬ κ΅¬ν˜„ν•©λ‹ˆλ‹€.
+
+///
+
+## `yield`와 `HTTPException`λ₯Ό μ‚¬μš©ν•˜λŠ” μ˜μ‘΄μ„±
+
+`yield`와 `try` λΈ”둝이 μžˆλŠ” μ˜μ‘΄μ„±μ„ μ‚¬μš©ν•˜μ—¬ μ˜ˆμ™Έλ₯Ό μ²˜λ¦¬ν•  μˆ˜ μžˆλ‹€λŠ” κ²ƒμ„ μ•Œκ²Œ λ˜μ—ˆμŠ΅λ‹ˆλ‹€.
+
+같은 λ°©μ‹μœΌλ‘œ, `yield` μ΄ν›„μ˜ μ’…λ£Œ μ½”λ“œμ—μ„œ `HTTPException`μ΄λ‚˜ μœ μ‚¬ν•œ μ˜ˆμ™Έλ₯Ό λ°œμƒμ‹œν‚¬ μˆ˜ μžˆμŠ΅λ‹ˆλ‹€.
+
+/// tip | νŒ
+
+μ΄λŠ” λ‹€μ†Œ κ³ κΈ‰ κΈ°μˆ μ΄λ©°, λŒ€λΆ€λΆ„μ˜ κ²½μš° κ²½λ‘œ μ—°μ‚° ν•¨μˆ˜ λ“± λ‚˜λ¨Έμ§€ μ• ν”Œλ¦¬μΌ€μ΄μ…˜ μ½”λ“œ λ‚΄λΆ€μ—μ„œ μ˜ˆμ™Έ (`HTTPException` ν¬ν•¨)λ₯Ό λ°œμƒμ‹œν‚¬ μˆ˜ μžˆμœΌλ―€λ‘œ μ‹€μ œλ‘œλŠ” ν•„μš”ν•˜μ§€ μ•Šμ„ κ²ƒμž…λ‹ˆλ‹€.
+
+ν•˜μ§€λ§Œ ν•„μš”ν•œ κ²½μš° μ‚¬μš©ν•  μˆ˜ μžˆμŠ΅λ‹ˆλ‹€. πŸ€“
+
+///
+
+{* ../../docs_src/dependencies/tutorial008b_an_py39.py hl[18:22,31] *}
+
+μ˜ˆμ™Έλ₯Ό μ²˜λ¦¬ν•˜κ³ (λ˜λŠ” μΆ”κ°€λ‘œ λ‹€λ₯Έ `HTTPException`을 λ°œμƒμ‹œν‚€κΈ° μœ„ν•΄) μ‚¬μš©ν•  μˆ˜ μžˆλŠ” λ˜ λ‹€λ₯Έ λ°©λ²•은 [μ‚¬μš©μž μ •μ˜ μ˜ˆμ™Έ μ²˜λ¦¬κΈ°](../handling-errors.md#install-custom-exception-handlers){.internal-link target=_blank}λ₯Ό μƒμ„±ν•˜λŠ” κ²ƒ μž…λ‹ˆλ‹€.
+
+## `yield`와 `except`λ₯Ό μ‚¬μš©ν•˜λŠ” μ˜μ‘΄μ„±
+
+`yield`λ₯Ό μ‚¬μš©ν•˜λŠ” μ˜μ‘΄μ„±μ—μ„œ `except`λ₯Ό μ‚¬μš©ν•˜μ—¬ μ˜ˆμ™Έλ₯Ό ν¬μ°©ν•˜κ³  μ˜ˆμ™Έλ₯Ό λ‹€μ‹œ λ°œμƒμ‹œν‚€μ§€ μ•Šκ±°λ‚˜ (λ˜λŠ” μƒˆ μ˜ˆμ™Έλ₯Ό λ°œμƒμ‹œν‚€μ§€ μ•ŠμœΌλ©΄), FastAPIλŠ” ν•΄λ‹Ή μ˜ˆμ™Έκ°€ λ°œμƒν–ˆλŠ”μ§€ μ•Œ μˆ˜ μ—†μŠ΅λ‹ˆλ‹€. μ΄λŠ” μΌλ°˜μ μΈ Python λ°©μ‹κ³Ό λ™μΌν•©λ‹ˆλ‹€:
+
+{* ../../docs_src/dependencies/tutorial008c_an_py39.py hl[15:16] *}
+
+이 κ²½μš°, `HTTPException`μ΄λ‚˜ μœ μ‚¬ν•œ μ˜ˆμ™Έλ₯Ό λ°œμƒμ‹œν‚€μ§€ μ•ŠκΈ° λ•Œλ¬Έμ— ν΄λΌμ΄μ–ΈνŠΈλŠ” HTTP 500 Internal Server Error μ‘닡을 λ³΄κ²Œ λ˜μ§€λ§Œ, μ„œλ²„λŠ” μ–΄λ–€ μ˜€λ₯˜κ°€ λ°œμƒν–ˆλŠ”μ§€μ— λŒ€ν•œ **둜그**λ‚˜ λ‹€λ₯Έ ν‘œμ‹œλ₯Ό μ „ν˜€ κ°€μ§€μ§€ μ•Šκ²Œ λ©λ‹ˆλ‹€. πŸ˜±
+
+### `yield`와 `except`λ₯Ό μ‚¬μš©ν•˜λŠ” μ˜μ‘΄μ„±μ—μ„œ ν•­μƒ `raise` ν•˜κΈ°
+
+`yield`κ°€ μžˆλŠ” μ˜μ‘΄μ„±μ—μ„œ μ˜ˆμ™Έλ₯Ό μž‘μ•˜μ„ λ•ŒλŠ” `HTTPException`μ΄λ‚˜ μœ μ‚¬ν•œ μ˜ˆμ™Έλ₯Ό μƒˆλ‘œ λ°œμƒμ‹œν‚€μ§€ μ•ŠλŠ” ν•œ, λ°˜λ“œμ‹œ μ›λž˜μ˜ μ˜ˆμ™Έλ₯Ό λ‹€μ‹œ λ°œμƒμ‹œμΌœμ•Ό ν•©λ‹ˆλ‹€.
+
+`raise`λ₯Ό μ‚¬μš©ν•˜μ—¬ λ™μΌν•œ μ˜ˆμ™Έλ₯Ό λ‹€μ‹œ λ°œμƒμ‹œν‚¬ μˆ˜ μžˆμŠ΅λ‹ˆλ‹€:
+
+{* ../../docs_src/dependencies/tutorial008d_an_py39.py hl[17] *}
+
+이제 ν΄λΌμ΄μ–ΈνŠΈλŠ” λ™μΌν•œ *HTTP 500 Internal Server Error* μ˜€λ₯˜ μ‘닡을 λ°›κ²Œ λ˜μ§€λ§Œ, μ„œλ²„ λ‘œκ·Έμ—λŠ” μ‚¬μš©μž μ •μ˜ μ˜ˆμ™ΈμΈ `InternalError"κ°€ κΈ°λ‘λ©λ‹ˆλ‹€. πŸ˜Ž
+
+## `yield`λ₯Ό μ‚¬μš©ν•˜λŠ” μ˜μ‘΄μ„±μ˜ μ‹€ν–‰ μˆœμ„œ
+
+μ‹€ν–‰ μˆœμ„œλŠ” μ•„λž˜ λ‹€μ΄μ–΄κ·Έλž¨κ³Ό κ±°μ˜ λΉ„μŠ·ν•©λ‹ˆλ‹€. μ‹œκ°„은 μœ„μ—μ„œ μ•„λž˜λ‘œ νλ¦…λ‹ˆλ‹€. κ·Έλ¦¬κ³  κ° μ—΄μ€ μƒν˜Έ μž‘μš©ν•˜κ±°λ‚˜ μ½”λ“œλ₯Ό μ‹€ν–‰ν•˜λŠ” λΆ€λΆ„ μ€‘ ν•˜λ‚˜μž…λ‹ˆλ‹€.
+
+```mermaid
+sequenceDiagram
+
+participant client as Client
+participant handler as Exception handler
+participant dep as Dep with yield
+participant operation as Path Operation
+participant tasks as Background tasks
+
+    Note over client,operation: Can raise exceptions, including HTTPException
+    client ->> dep: Start request
+    Note over dep: Run code up to yield
+    opt raise Exception
+        dep -->> handler: Raise Exception
+        handler -->> client: HTTP error response
+    end
+    dep ->> operation: Run dependency, e.g. DB session
+    opt raise
+        operation -->> dep: Raise Exception (e.g. HTTPException)
+        opt handle
+            dep -->> dep: Can catch exception, raise a new HTTPException, raise other exception
+        end
+        handler -->> client: HTTP error response
+    end
+
+    operation ->> client: Return response to client
+    Note over client,operation: Response is already sent, can't change it anymore
+    opt Tasks
+        operation -->> tasks: Send background tasks
+    end
+    opt Raise other exception
+        tasks -->> tasks: Handle exceptions in the background task code
+    end
+```
+
+/// info | μ •보
+
+ν΄λΌμ΄μ–ΈνŠΈμ— **ν•˜λ‚˜μ˜ μ‘λ‹΅** λ§Œ μ „μ†‘λ©λ‹ˆλ‹€. μ΄λŠ” μ˜€λ₯˜ μ‘λ‹΅ μ€‘ ν•˜λ‚˜μΌ μˆ˜λ„ μžˆκ³ ,*경둜 μž‘μ—…*μ—μ„œ μƒμ„±λœ μ‘닡일 μˆ˜λ„ μžˆμŠ΅λ‹ˆλ‹€.
+
+μ΄λŸ¬ν•œ μ‘λ‹΅ μ€‘ ν•˜λ‚˜κ°€ μ „솑된 ν›„μ—λŠ” λ‹€λ₯Έ μ‘닡을 λ³΄λ‚Ό μˆ˜ μ—†μŠ΅λ‹ˆλ‹€.
+
+///
+
+/// tip | νŒ
+
+이 λ‹€μ΄μ–΄κ·Έλž¨μ€ `HTTPException`을 λ³΄μ—¬μ£Όμ§€λ§Œ, `yield`λ₯Ό μ‚¬μš©ν•˜λŠ” μ˜μ‘΄μ„±μ—μ„œ μ²˜λ¦¬ν•œ μ˜ˆμ™Έλ‚˜ [μ‚¬μš©μž μ •μ˜ μ˜ˆμ™Έμ²˜λ¦¬κΈ°](../handling-errors.md#install-custom-exception-handlers){.internal-link target=_blank}.λ₯Ό μ‚¬μš©ν•˜μ—¬ μ²˜λ¦¬ν•œ λ‹€λ₯Έ μ˜ˆμ™Έλ„ λ°œμƒμ‹œν‚¬ μˆ˜ μžˆμŠ΅λ‹ˆλ‹€.
+
+μ–΄λ–€ μ˜ˆμ™Έκ°€ λ°œμƒν•˜λ“ , `HTTPException`을 ν¬ν•¨ν•˜μ—¬ yieldλ₯Ό μ‚¬μš©ν•˜λŠ” μ˜μ‘΄μ„±μœΌλ‘œ μ „λ‹¬λ©λ‹ˆλ‹€. λŒ€λΆ€λΆ„μ˜ κ²½μš° μ˜ˆμ™Έλ₯Ό λ‹€μ‹œ λ°œμƒμ‹œν‚€κ±°λ‚˜ μƒˆλ‘œμš΄ μ˜ˆμ™Έλ₯Ό λ°œμƒμ‹œμΌœμ•Ό ν•©λ‹ˆλ‹€.
+
+///
+
+## `yield`, `HTTPException`, `except` λ° λ°±κ·ΈλΌμš΄λ“œ μž‘업을 μ‚¬μš©ν•˜λŠ” μ˜μ‘΄μ„±
+
+/// warning | κ²½κ³ 
+
+μ΄λŸ¬ν•œ κΈ°μˆ μ  μ„ΈλΆ€ μ‚¬ν•­μ€ λŒ€λΆ€λΆ„ ν•„μš”ν•˜μ§€ μ•ŠμœΌλ―€λ‘œ μ΄ μ„Ήμ…˜μ„ κ±΄λ„ˆλ›°κ³  μ•„λž˜μ—μ„œ κ³„속 μ§„행해도 λ©λ‹ˆλ‹€.
+
+μ΄λŸ¬ν•œ μ„ΈλΆ€ μ •λ³΄λŠ” μ£Όλ‘œ FastAPI 0.106.0 μ΄μ „ λ²„μ „μ—μ„œ `yield`κ°€ μžˆλŠ” μ˜μ‘΄μ„±μ˜ λ¦¬μ†ŒμŠ€λ₯Ό λ°±κ·ΈλΌμš΄λ“œ μž‘μ—…μ—μ„œ μ‚¬μš©ν–ˆλ˜ κ²½μš°λ©” μœ μš©ν•©λ‹ˆλ‹€.
+
+///
+
+### `yield`와 `except`λ₯Ό μ‚¬μš©ν•˜λŠ” μ˜μ‘΄μ„±, κΈ°μˆ  μ„ΈλΆ€μ‚¬ν•­
+
+FastAPI 0.110.0 μ΄μ „μ—λŠ” `yield`κ°€ ν¬ν•¨λœ μ˜μ‘΄μ„±μ„ μ‚¬μš©ν•œ ν›„ ν•΄λ‹Ή μ˜μ‘΄μ„±μ—μ„œ `except`κ°€ ν¬ν•¨λœ μ˜ˆμ™Έλ₯Ό μΊ‘μ²˜ν•˜κ³  λ‹€μ‹œ μ˜ˆμ™Έλ₯Ό λ°œμƒμ‹œν‚€μ§€ μ•ŠμœΌλ©΄ μ˜ˆμ™Έκ°€ μžλ™μœΌλ‘œ μ˜ˆμ™Έ ν•Έλ“€λŸ¬ λ˜λŠ” λ‚΄λΆ€ μ„œλ²„ μ˜€λ₯˜ ν•Έλ“€λŸ¬λ‘œ λ°œμƒ/μ „λ‹¬λ˜μ—ˆμŠ΅λ‹ˆλ‹€.
+
+μ΄λŠ” μ²˜λ¦¬κΈ° μ—†μ΄ μ „λ‹¬λœ μ˜ˆμ™Έ(λ‚΄λΆ€ μ„œλ²„ μ˜€λ₯˜)μ—μ„œ μ²˜λ¦¬λ˜μ§€ μ•Šμ€ λ©”λͺ¨λ¦¬ μ†ŒλΉ„λ₯Ό μˆ˜μ •ν•˜κ³  μΌλ°˜ νŒŒμ΄μ¬ μ½”λ“œμ˜ λ™μž‘κ³Ό μΌμΉ˜ν•˜λ„둝 ν•˜κΈ° μœ„ν•΄ 0.110.0 λ²„μ „μ—μ„œ λ³€κ²½λ˜μ—ˆμŠ΅λ‹ˆλ‹€.
+
+### λ°±κ·ΈλΌμš΄λ“œ μž‘μ—…κ³Ό `yield`λ₯Ό μ‚¬μš©ν•˜λŠ” μ˜μ‘΄μ„±, κΈ°μˆ  μ„ΈλΆ€μ‚¬ν•­
+
+FastAPI 0.106.0 μ΄μ „μ—λŠ” `yield` μ΄ν›„에 μ˜ˆμ™Έλ₯Ό λ°œμƒμ‹œν‚€λŠ” κ²ƒμ΄ λΆˆκ°€λŠ₯ν–ˆμŠ΅λ‹ˆλ‹€. `yield`κ°€ μžˆλŠ” μ˜μ‘΄μ„± μ’…λ£Œ μ½”λ“œλŠ” μ‘닡이 μ „솑된 μ΄ν›„에 μ‹€ν–‰λ˜μ—ˆκΈ° λ•Œλ¬Έμ—, [μ˜ˆμ™Έ μ²˜λ¦¬κΈ°](../handling-errors.md#install-custom-exception-handlers){.internal-link target=_blank}κ°€ μ΄λ―Έ μ‹€ν–‰λœ μƒνƒœμ˜€μŠ΅λ‹ˆλ‹€.
+
+μ΄λŠ” μ£Όλ‘œ λ°±κ·ΈλΌμš΄λ“œ μž‘μ—… λ‚΄μ—μ„œ μ˜μ‘΄μ„±μ—μ„œ "yield된" λ™μΌν•œ κ°μ²΄λ₯Ό μ‚¬μš©ν•  μˆ˜ μžˆλ„둝 ν•˜κΈ° μœ„ν•΄ μ΄λŸ° λ°©μ‹μœΌλ‘œ μ„€κ³„λ˜μ—ˆμŠ΅λ‹ˆλ‹€. μ’…λ£Œ μ½”λ“œλŠ” λ°±κ·ΈλΌμš΄λ“œ μž‘업이 μ™„λ£Œλœ ν›„에 μ‹€ν–‰λ˜μ—ˆκΈ° λ•Œλ¬Έμž…λ‹ˆλ‹€
+
+ν•˜μ§€λ§Œ μ΄λ ‡κ²Œ ν•˜λ©΄ λ¦¬μ†ŒμŠ€λ₯Ό λΆˆν•„μš”ν•˜κ²Œ μ–‘λ³΄ν•œ μ˜μ‘΄μ„±(예: λ°μ΄ν„°λ² μ΄μŠ€ μ—°κ²°)μ—μ„œ λ³΄μœ ν•˜λ©΄μ„œ μ‘닡이 λ„€νŠΈμ›Œν¬λ₯Ό ν†΅ν•΄ μ΄λ™ν•  λ•ŒκΉŒμ§€ κΈ°λ‹€λ¦¬λŠ” κ²ƒμ„ μ˜λ―Έν•˜κΈ° λ•Œλ¬Έμ— FastAPI 0.106.0μ—μ„œ λ³€κ²½λ˜μ—ˆμŠ΅λ‹ˆλ‹€.
+
+/// tip | νŒ
+
+λ˜ν•œ λ°±κ·ΈλΌμš΄λ“œ μž‘업은 μΌλ°˜μ μœΌλ‘œ μžμ²΄ λ¦¬μ†ŒμŠ€(예: μžμ²΄ λ°μ΄ν„°λ² μ΄μŠ€ μ—°κ²°)λ₯Ό μ‚¬μš©ν•˜μ—¬ λ³„λ„λ‘œ μ²˜λ¦¬ν•΄μ•Ό ν•˜λŠ” λ…립적인 λ‘œμ§ μ§‘ν•©μž…λ‹ˆλ‹€.
+
+λ”°λΌμ„œ μ΄λ ‡κ²Œ ν•˜λ©΄ μ½”λ“œκ°€ λ” κΉ”λ”ν•΄μ§‘λ‹ˆλ‹€.
+
+///
+
+λ§Œμ•½ μ΄μ „에 μ΄λŸ¬ν•œ λ™μž‘에 μ˜μ‘΄ν–ˆλ‹€λ©΄, μ΄μ œλŠ” λ°±κ·ΈλΌμš΄λ“œ μž‘μ—… λ‚΄λΆ€μ—μ„œ λ°±κ·ΈλΌμš΄λ“œ μž‘업을 μœ„ν•œ λ¦¬μ†ŒμŠ€λ₯Ό μƒμ„±ν•˜κ³ , `yield`κ°€ μžˆλŠ” μ˜μ‘΄μ„±μ˜ λ¦¬μ†ŒμŠ€μ— μ˜μ‘΄ν•˜μ§€ μ•ŠλŠ” λ°μ΄ν„°λ§Œ λ‚΄λΆ€μ μœΌλ‘œ μ‚¬μš©ν•΄μ•Όν•©λ‹ˆλ‹€.
+
+예λ₯Ό λ“€μ–΄, λ™μΌν•œ λ°μ΄ν„°λ² μ΄μŠ€ μ„Έμ…˜μ„ μ‚¬μš©ν•˜λŠ” λŒ€μ‹ , λ°±κ·ΈλΌμš΄λ“œ μž‘μ—… λ‚΄λΆ€μ—μ„œ μƒˆλ‘œμš΄ λ°μ΄ν„°λ² μ΄μŠ€ μ„Έμ…˜μ„ μƒμ„±ν•˜κ³  μ΄ μƒˆλ‘œμš΄ μ„Έμ…˜μ„ μ‚¬μš©ν•˜μ—¬ λ°μ΄ν„°λ² μ΄μŠ€μ—μ„œ κ°μ²΄λ₯Ό κ°€μ Έμ™€μ•Ό ν•©λ‹ˆλ‹€. κ·Έλ¦¬κ³  λ°μ΄ν„°λ² μ΄μŠ€ κ°μ²΄λ₯Ό λ°±κ·ΈλΌμš΄λ“œ μž‘μ—… ν•¨μˆ˜μ˜ λ§€κ°œλ³€μˆ˜λ‘œ μ§μ ‘ μ „λ‹¬ν•˜λŠ” λŒ€μ‹ , ν•΄λ‹Ή κ°μ²΄μ˜ IDλ₯Ό μ „λ‹¬ν•œ λ‹€μŒ λ°±κ·ΈλΌμš΄λ“œ μž‘μ—… ν•¨μˆ˜ λ‚΄λΆ€μ—μ„œ κ°μ²΄λ₯Ό λ‹€μ‹œ κ°€μ Έμ™€μ•Ό ν•©λ‹ˆλ‹€
+
+## μ»¨ν…μŠ€νŠΈ κ΄€λ¦¬μž
+
+### "μ»¨ν…μŠ€νŠΈ κ΄€λ¦¬μž"λž€?
+
+"μ»¨ν…μŠ€νŠΈ κ΄€λ¦¬μž"λŠ” Pythonμ—μ„œ `with` λ¬Έμ—μ„œ μ‚¬μš©ν•  μˆ˜ μžˆλŠ” λͺ¨λ“  κ°μ²΄λ₯Ό μ˜λ―Έν•©λ‹ˆλ‹€.
+
+예λ₯Ό λ“€μ–΄, <a href="https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files" class="external-link" target="_blank"> `with`λ₯Ό μ‚¬μš©ν•˜μ—¬ νŒŒμΌμ„ μ½μ„ μˆ˜ μžˆμŠ΅λ‹ˆλ‹€</a>:
+
+```Python
+with open("./somefile.txt") as f:
+    contents = f.read()
+    print(contents)
+```
+
+λ‚΄λΆ€μ μœΌλ‘œ `open("./somefile.txt")` λŠ” "μ»¨ν…μŠ€νŠΈ κ΄€λ¦¬μž(Context Manager)"라고 λΆˆλ¦¬λŠ” κ°μ²΄λ₯Ό μƒμ„±ν•©λ‹ˆλ‹€.
+
+`with` λΈ”둝이 λλ‚˜λ©΄, μ˜ˆμ™Έκ°€ λ°œμƒν–ˆλ”라도 νŒŒμΌμ„ λ‹«λ„둝 λ³΄μž₯ν•©λ‹ˆλ‹€.
+
+`yield`κ°€ μžˆλŠ” μ˜μ‘΄μ„±μ„ μƒμ„±ν•˜λ©΄ **FastAPI**λŠ” λ‚΄λΆ€μ μœΌλ‘œ μ΄λ₯Ό μœ„ν•œ μ»¨ν…μŠ€νŠΈ λ§€λ‹ˆμ €λ₯Ό μƒμ„±ν•˜κ³  λ‹€λ₯Έ κ΄€λ ¨ λ„ꡬ듀과 κ²°ν•©ν•©λ‹ˆλ‹€.
+
+### `yield`λ₯Ό μ‚¬μš©ν•˜λŠ” μ˜μ‘΄μ„±μ—μ„œ μ»¨ν…μŠ€νŠΈ κ΄€λ¦¬μž μ‚¬μš©ν•˜κΈ°
+
+/// warning | κ²½κ³ 
+
+이것은 μ–΄λА μ •도 "κ³ κΈ‰" κ°œλ…μž…λ‹ˆλ‹€.
+
+**FastAPI**λ₯Ό μ²˜μŒ μ‹œμž‘ν•˜λŠ” κ²½μš° μ§€κΈˆμ€ μ΄ λΆ€λΆ„을 κ±΄λ„ˆλ›°μ–΄λ„ μ’‹μŠ΅λ‹ˆλ‹€.
+
+///
+
+Pythonμ—μ„œλŠ” λ‹€μŒμ„ ν†΅ν•΄ μ»¨ν…μŠ€νŠΈ κ΄€λ¦¬μžλ₯Ό μƒμ„±ν•  μˆ˜ μžˆμŠ΅λ‹ˆλ‹€. <a href="https://docs.python.org/3/reference/datamodel.html#context-managers" class="external-link" target="_blank"> λ‘ κ°€μ§€ λ©”μ„œλ“œκ°€ μžˆλŠ” ν΄λž˜μŠ€λ₯Ό μƒμ„±ν•©λ‹ˆλ‹€: `__enter__()` and `__exit__()`</a>.
+
+**FastAPI**의 `yield`κ°€ μžˆλŠ” μ˜μ‘΄μ„± λ‚΄μ—μ„œ
+`with` λ˜λŠ” `async with`문을 μ‚¬μš©ν•˜μ—¬ μ΄λ“€μ„ ν™œμš©ν•  μˆ˜ μžˆμŠ΅λ‹ˆλ‹€:
+
+{* ../../docs_src/dependencies/tutorial010.py hl[1:9,13] *}
+
+/// tip | νŒ
+
+μ»¨ν…μŠ€νŠΈ κ΄€λ¦¬μžλ₯Ό μƒμ„±ν•˜λŠ” λ˜ λ‹€λ₯Έ λ°©λ²•은 λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€:
+
+* <a href="https://docs.python.org/3/library/contextlib.html#contextlib.contextmanager" class="external-link" target="_blank">`@contextlib.contextmanager`</a> λ˜λŠ”
+* <a href="https://docs.python.org/3/library/contextlib.html#contextlib.asynccontextmanager" class="external-link" target="_blank">`@contextlib.asynccontextmanager`</a>
+
+이듀은 λ‹¨μΌ `yield`κ°€ μžˆλŠ” ν•¨μˆ˜λ₯Ό κΎΈλ―ΈλŠ” λ° μ‚¬μš©ν•©λ‹ˆλ‹€.
+
+이것이 **FastAPI**κ°€ `yield`κ°€ μžˆλŠ” μ˜μ‘΄μ„±μ„ μœ„ν•΄ λ‚΄λΆ€μ μœΌλ‘œ μ‚¬μš©ν•˜λŠ” λ°©μ‹μž…λ‹ˆλ‹€.
+
+ν•˜μ§€λ§Œ FastAPI μ˜μ‘΄μ„±μ—λŠ” μ΄λŸ¬ν•œ λ°μ½”λ ˆμ΄ν„°λ₯Ό μ‚¬μš©ν•  ν•„μš”κ°€ μ—†μŠ΅λ‹ˆλ‹€(그리고 μ‚¬μš©ν•΄μ„œλ„ μ•ˆλ©λ‹ˆλ‹€).
+
+FastAPIκ°€ λ‚΄λΆ€μ μœΌλ‘œ μ΄λ₯Ό μ²˜λ¦¬ν•΄ μ€„ κ²ƒμž…λ‹ˆλ‹€.
+
+///