Browse Source

๐ŸŒ Add Korean translation for `docs/ko/docs/advanced/events.md` (#5087)

pull/4492/merge
Dong-Young Kim 1 year ago
committed by GitHub
parent
commit
c964d04004
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 45
      docs/ko/docs/advanced/events.md

45
docs/ko/docs/advanced/events.md

@ -0,0 +1,45 @@
# ์ด๋ฒคํŠธ: startup๊ณผ shutdown
ํ•„์š”์— ๋”ฐ๋ผ ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์ด ์‹œ์ž‘๋˜๊ธฐ ์ „์ด๋‚˜ ์ข…๋ฃŒ๋  ๋•Œ ์‹คํ–‰๋˜๋Š” ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ(ํ•จ์ˆ˜)๋ฅผ ์ •์˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์ด ํ•จ์ˆ˜๋“ค์€ `async def` ๋˜๋Š” ํ‰๋ฒ”ํ•˜๊ฒŒ `def`์œผ๋กœ ์„ ์–ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
!!! warning "๊ฒฝ๊ณ "
์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ๋Š” ์ฃผ ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์—์„œ๋งŒ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค. [ํ•˜์œ„ ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ - ๋งˆ์šดํŠธ](./sub-applications.md){.internal-link target=_blank}์—์„œ๋Š” ์ž‘๋™ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
## `startup` ์ด๋ฒคํŠธ
์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์„ ์‹œ์ž‘ํ•˜๊ธฐ ์ „์— ์‹คํ–‰ํ•˜๋ ค๋Š” ํ•จ์ˆ˜๋ฅผ "startup" ์ด๋ฒคํŠธ๋กœ ์„ ์–ธํ•ฉ๋‹ˆ๋‹ค:
```Python hl_lines="8"
{!../../../docs_src/events/tutorial001.py!}
```
์ด ๊ฒฝ์šฐ `startup` ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ ํ•จ์ˆ˜๋Š” ๋‹จ์ˆœํžˆ ๋ช‡ ๊ฐ€์ง€ ๊ฐ’์œผ๋กœ ๊ตฌ์„ฑ๋œ `dict` ํ˜•์‹์˜ "๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค"๋ฅผ ์ดˆ๊ธฐํ™”ํ•ฉ๋‹ˆ๋‹ค.
ํ•˜๋‚˜ ์ด์ƒ์˜ ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ ํ•จ์ˆ˜๋ฅผ ์ถ”๊ฐ€ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.
๊ทธ๋ฆฌ๊ณ  ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์€ ๋ชจ๋“  `startup` ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ๊ฐ€ ์™„๋ฃŒ๋  ๋•Œ๊นŒ์ง€ ์š”์ฒญ์„ ๋ฐ›์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
## `shutdown` ์ด๋ฒคํŠธ
์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์ด ์ข…๋ฃŒ๋  ๋•Œ ์‹คํ–‰ํ•˜๋ ค๋Š” ํ•จ์ˆ˜๋ฅผ ์ถ”๊ฐ€ํ•˜๋ ค๋ฉด `"shutdown"` ์ด๋ฒคํŠธ๋กœ ์„ ์–ธํ•ฉ๋‹ˆ๋‹ค:
```Python hl_lines="6"
{!../../../docs_src/events/tutorial002.py!}
```
์ด ์˜ˆ์ œ์—์„œ `shutdown` ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ ํ•จ์ˆ˜๋Š” `"Application shutdown"`์ด๋ผ๋Š” ํ…์ŠคํŠธ๊ฐ€ ์ ํžŒ `log.txt` ํŒŒ์ผ์„ ์ถ”๊ฐ€ํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค.
!!! info "์ •๋ณด"
`open()` ํ•จ์ˆ˜์—์„œ `mode="a"`๋Š” "์ถ”๊ฐ€"๋ฅผ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์ด๋ฏธ ์กด์žฌํ•˜๋Š” ํŒŒ์ผ์˜ ๋‚ด์šฉ์„ ๋ฎ์–ด์“ฐ์ง€ ์•Š๊ณ  ์ƒˆ๋กœ์šด ์ค„์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.
!!! tip "ํŒ"
์ด ์˜ˆ์ œ์—์„œ๋Š” ํŒŒ์ผ๊ณผ ์ƒํ˜ธ์ž‘์šฉ ํ•˜๊ธฐ ์œ„ํ•ด ํŒŒ์ด์ฌ ํ‘œ์ค€ ํ•จ์ˆ˜์ธ `open()`์„ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.
๋”ฐ๋ผ์„œ ๋””์Šคํฌ์— ๋ฐ์ดํ„ฐ๋ฅผ ์“ฐ๊ธฐ ์œ„ํ•ด "๋Œ€๊ธฐ"๊ฐ€ ํ•„์š”ํ•œ I/O (์ž…๋ ฅ/์ถœ๋ ฅ) ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค.
๊ทธ๋Ÿฌ๋‚˜ `open()`์€ `async`์™€ `await`์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ ํ•จ์ˆ˜๋Š” `async def`๊ฐ€ ์•„๋‹Œ ํ‘œ์ค€ `def`๋กœ ์„ ์–ธํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.
!!! info "์ •๋ณด"
์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ์— ๊ด€ํ•œ ๋‚ด์šฉ์€ <a href="https://www.starlette.io/events/" class="external-link" target="_blank">Starlette ์ด๋ฒคํŠธ ๋ฌธ์„œ</a>์—์„œ ์ถ”๊ฐ€๋กœ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
Loadingโ€ฆ
Cancel
Save