SlideShare a Scribd company logo
๋น„๋™๊ธฐ 101
Basic of Asynchronous
๋‘ ๋ฒˆ์งธ
์ด๋ฏผ์ฒ 
๋น„๋™๊ธฐ๋ฅผ ์œ„ํ•œ python ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋“ค..
โ€ข Tornado
โ€ข call back ์Šคํƒ€์ผ์„ ์‚ฌ์šฉํ•˜๋Š” ๋น„๋™๊ธฐ ์›น ํ”„๋ ˆ์ž„ ์›Œํฌ
โ€ข Gevent
โ€ข Green thread ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” non blocking network I/O ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ
โ€ข Twisted
โ€ข Event-driven ๋ฐฉ์‹์˜ ๋น„๋™๊ธฐ network ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ
callback
โ€ข ๋น„๋™๊ธฐ ๋ฃจํ‹ด์ด ๋๋‚˜๋ฉด ์‹คํ–‰ํ•  ํ•จ์ˆ˜๋ฅผ ๊ฐ™์ด ๋„˜๊ฒจ์ค€๋‹ค
โ‡’์ž‘์—…์ด ๋๋‚˜๋ฉด ํ•ด๋‹น ํ•จ์ˆ˜๋ฅผ ์‹คํ–‰ ํ•ด ์คŒ
โ€ข โ€œ์ „ํ™”๋ฒˆํ˜ธ ๋‚จ๊ฒจ๋“œ๋ฆด ํ…Œ๋‹ˆ ์ผ ๋๋‚˜๋ฉด ์ „ํ™” ๋ถ€ํƒํ•ด์š”โ€
callback
callback
โ€ข execute_washer -> execute_dryer -> fold_laundry
โ‡’ execute_washer ํ•จ์ˆ˜ ์•ˆ์— execute_dryer์˜ ํ•ธ๋“ค๋Ÿฌ ํ•จ์ˆ˜ ์•ˆ์—
fold_laundry ํ•ธ๋“ค๋Ÿฌ ํ•จ์ˆ˜๋ฅผ ์ž‘์„ฑ ํ•ด์•ผ ํ•จ
โ€ข Callback chain์ด ๋” ๊ธธ์–ด์ง€๋ฉด?
=> ํ•จ์ˆ˜ ์•ˆ์— ์žˆ๋Š” callback ํ•จ์ˆ˜ ์•ˆ์— ์žˆ๋Š” callback ์•ˆ์— ์žˆ๋Š” callback
์•ˆ์— โ€ฆ
Callback hell
Gevent and greed thread
โ€ข Green thread:
thread๋ฅผ os ๋‚˜ ํ•˜๋“œ์›จ์–ด๊ฐ€ ์ œ์–ดํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ software level ์—์„œ ์ง
์ ‘ ์ œ์–ดํ•œ๋‹ค.
โ€ข ํšจ์œจ์ ์ด๊ณ  ์กฐ๊ธˆ ๋” ๋น ๋ฅธ thread ๊ฐ„์˜ context switching ์ด ๊ฐ€
๋Šฅํ•˜๋‹ค.
โ€ข Context switching ์˜ ์ด์ ์„ ๋นผ๋ฉด thread์˜ ๋ฌธ์ œ์ ์„ ๊ทธ๋Œ€๋กœ
๊ฐ€์ง€๊ณ  ์žˆ๋‹ค (๊ณต์œ  data ์ ‘๊ทผ ๋ฌธ์ œ ๋“ฑ..)
Green thread VS callback
Green thread
โ€ข Thread๋“ค์ด ํ•˜๋“œ์›จ์–ด ๋Œ€์‹  application ๋ ˆ๋ฒจ์—์„œ ๊ด€๋ฆฌ๋œ๋‹ค
โ€ข ์ผ๋ฐ˜ thread ์™€ ์œ ์‚ฌํ•จ: thread ๋ฅผ ์ดํ•ดํ•˜๊ณ  ์žˆ๋Š” ์‚ฌ๋žŒ์ด ์‚ฌ์šฉํ•˜๊ธฐ ์ข‹๋‹ค
โ€ข Cpu context switching ๋ฌธ์ œ๋ฅผ ์ œ์™ธํ•œ ์ผ๋ฐ˜ thread programming ์ด ๊ฐ€์ง„ ๋ชจ๋“  ๋ฌธ์ œ์ ์„ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค
Callback
โ€ข Thread ํ”„๋กœ๊ทธ๋žจ๊ณผ ๋งŽ์€ ๋ถ€๋ถ„์ด ๋‹ค๋ฅด๋‹ค
โ€ข ํ”„๋กœ๊ทธ๋ž˜๋จธ๋Š” thread์™€ ์ฝ”๋ฃจํ‹ด์„ ์ง์ ‘ ๋ณด๊ฑฐ๋‚˜ ์ œ์–ด ํ•  ์ˆ˜ ์—†๋‹ค
โ€ข Callback์€ ์˜ˆ์™ธ๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค์ง€ ์•Š๋Š”๋‹ค
โ€ข Callback์€ ์ˆ˜์ง‘ ํ•  ์ˆ˜ ์—†๋‹ค
โ€ข Callback ์˜ callback์€ ๋ณต์žกํ•˜๋ฉฐ ๋””๋ฒ„๊น…์ด ์–ด๋ ต๋‹ค
https://hackernoon.com/asynchronous-python-45df84b82434
์ด๊ฒŒ ์ตœ์„ ์ธ๊ฐ€์š”
โ€ข ๋„ค. Python 3.3 (2012๋…„ ๋ฐœํ‘œ) ์ „ ๊นŒ์ง€๋Š”์š”
์ด๊ฒŒ ์ตœ์„ ์ธ๊ฐ€์š”
โ€ข Python3.3 generator yield from ๋ฌธ๋ฒ• ์ง€์›
โ€ข asyncio ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์˜(์ฝ”๋ฃจํ‹ด๊ณผ ๋น„๋™๊ธฐ event loop๋ฅผ ์ ๊ทน ํ™œ์šฉ)
๋ฐœ์ „
โ€ข Python3.4 asyncio ๋ฅผ ๋ฌด๋ ค built-in ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋กœ ์ œ๊ณต
โ€ข Python3.5 async / await ๋ฌธ๋ฒ• ์ง€์›
Iterable
โ€ข ์ง์—ญํ•˜๋ฉด โ€˜๋ฐ˜๋ณต ๊ฐ€๋Šฅํ•œโ€™
โ€ข for loop์œผ๋กœ ์“ฐ์ผ ์ˆ˜ ์žˆ๋Š” ๋ชจ๋“  ๊ฐ์ฒด == iterable object
โ€ข Ex: list, str, tuple โ€ฆ
Iterator
โ€ข next(iterator) ๋ฉ”์„œ๋“œ๋กœ ์ˆœ์ฐจ์ ์œผ๋กœ ๋ฐ์ดํ„ฐ ์ ‘๊ทผ
โ€ข ๋ชจ๋“  ์š”์†Œ๋ฅผ ์ˆœํšŒํ–ˆ์œผ๋ฉด (๋” ์ด์ƒ์˜ ์š”์†Œ๊ฐ€ ์—†๋‹ค๋ฉด) next ํ˜ธ์ถœ์‹œ
์— StopIteration Exception ๋ฐœ์ƒ
โ€ข Iterable object๋ฅผ for loop ์•ˆ์— ๋„ฃ์œผ๋ฉด python ๋‚ด๋ถ€์ ์œผ๋กœ
iterator๋กœ ๋ณ€ํ™˜ ํ•˜์—ฌ ์ˆœํ™˜ํ•œ๋‹ค
Iterator
Iterable object ๋ฅผ iterator ๋กœ ๋ณ€ํ™˜
Iterator
Generator
โ€ข ์กฐ๊ธˆ ๋” ์ง„๋ณด๋œ ํ˜•ํƒœ์˜ iterator
โ€ข yield ํ‚ค์›Œ๋“œ๋ฅผ ํ†ตํ•ด ์™ธ๋ถ€๋กœ๋ถ€ํ„ฐ ๋ฐ์ดํ„ฐ๋ฅผ ์ž…๋ ฅ ๋ฐ›๊ฑฐ๋‚˜ ์™ธ๋ถ€๋กœ
๋ฐ์ดํ„ฐ๋ฅผ ์ถœ๋ ฅ ํ•  ์ˆ˜ ์žˆ๋‹ค
โ€ข next(generator) ๋ฉ”์„œ๋“œ๋กœ ๋‹ค์Œ yield ์ถœ๋ ฅ ๊ฐ’ ๋ฆฌํ„ด
Generator
โ€ข ์กฐ๊ธˆ ๋” ์ง„๋ณด๋œ ํ˜•ํƒœ์˜ iterator (generator ์—ญ์‹œ for๋กœ ๋ฐ˜๋ณต๊ฐ€๋Šฅ)
โ€ข yield ํ‚ค์›Œ๋“œ๋ฅผ ํ†ตํ•ด ์™ธ๋ถ€๋กœ๋ถ€ํ„ฐ ๋ฐ์ดํ„ฐ๋ฅผ ์ž…๋ ฅ ๋ฐ›๊ฑฐ๋‚˜ ์™ธ๋ถ€๋กœ
๋ฐ์ดํ„ฐ๋ฅผ ์ถœ๋ ฅ ํ•  ์ˆ˜ ์žˆ๋‹ค
โ€ข next(generator) ๋ฉ”์„œ๋“œ๋กœ ๋‹ค์Œ yield ์ถœ๋ ฅ ๊ฐ’ ๋ฆฌํ„ด
Generator
yield ํ‚ค์›Œ๋“œ๊ฐ€ ์žˆ์œผ๋ฉด generator๋กœ ์ธ์‹
Generator
Generator
yield from
โ€ข Generator ๋‚ด์—์„œ iterator, generator ์˜ ๋ชจ๋“  ์š”์†Œ๋ฅผ yield ํ• 
๋•Œ ์‚ฌ์šฉ
โ€ข Generator๋ฅผ yield from ํ•  ๋•Œ๋Š” return ์„ ๋ฐ›์•„ ์˜ฌ ์ˆ˜ ์žˆ๋‹ค
yield from
yield from
์ฝ”๋ฃจํ‹ด
โ€ข ๋ฃจํ‹ด์„ ์ง„ํ–‰ํ•˜๋Š” ์ค‘๊ฐ„์— ๋ฉˆ์ถ”์–ด์„œ ํŠน์ • ์œ„์น˜๋กœ ๋Œ์•„๊ฐ”๋‹ค๊ฐ€ ๋‹ค
์‹œ ์›๋ž˜ ์œ„์น˜๋กœ ๋Œ์•„์™€ ๋‚˜๋จธ์ง€ ๋ฃจํ‹ด์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ๋‹ค
โ‡’์ง„์ž…์ ์ด ์—ฌ๋Ÿฌ ๊ฐœ์ธ ๋ฃจํ‹ด
์‹œ๊ฐ„
์ค‘๋‹จ ์žฌ๊ฐœ
Coroutine
์žฌ๊ฐœ์ค‘๋‹จ
์ฝ”๋ฃจํ‹ด
์‹œ๊ฐ„
์ค‘๋‹จ ์žฌ๊ฐœ
Coroutine
์žฌ๊ฐœ์ค‘๋‹จ์‹œ์ž‘ ์ข…๋ฃŒ
์‹œ๊ฐ„
yield next
Generator
nextyeildnext StopIteration
Python asyncio coroutine
Python coroutine with async/await
asyncio Event Loop
asyncio Event Loop
โ€ข loop.run_until_complete
โ€ข loop.run_forever
โ€ข loop.call_soon
โ€ข loop.stop
โ€ข loop.run_in_executor
asyncio Event Loop
asyncio document
โ€ข https://docs.python.org/3.4/library/asyncio-task.html
โ€ข https://docs.python.org/3/library/asyncio-eventloop.html
awesome asyncio
โ€ข https://github.com/timofurrer/awesome-asyncio

More Related Content

What's hot

R2์„œ๋ฒ„์ •์ง„์šฑ
R2์„œ๋ฒ„์ •์ง„์šฑR2์„œ๋ฒ„์ •์ง„์šฑ
R2์„œ๋ฒ„์ •์ง„์šฑjungjinwouk
ย 
Optimizing merge program
Optimizing merge program Optimizing merge program
Optimizing merge program
CHANG-HYUN LEE
ย 
Iocp advanced
Iocp advancedIocp advanced
Iocp advanced
Nam Hyeonuk
ย 
Microsoft pp lpdf
Microsoft pp lpdfMicrosoft pp lpdf
Microsoft pp lpdf
HYUNWOO KIM
ย 
PyCon 12์›” ์„ธ๋ฏธ๋‚˜ - ์‹ค์ „ ํŒŒ์ด์ฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ฑ… ํ™๋ณด
PyCon 12์›” ์„ธ๋ฏธ๋‚˜ - ์‹ค์ „ ํŒŒ์ด์ฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ฑ… ํ™๋ณดPyCon 12์›” ์„ธ๋ฏธ๋‚˜ - ์‹ค์ „ ํŒŒ์ด์ฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ฑ… ํ™๋ณด
PyCon 12์›” ์„ธ๋ฏธ๋‚˜ - ์‹ค์ „ ํŒŒ์ด์ฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ฑ… ํ™๋ณด
Young Hoo Kim
ย 
๊ฒŒ์ž„์„œ๋ฒ„ํ”„๋กœ๊ทธ๋ž˜๋ฐ #1 - IOCP
๊ฒŒ์ž„์„œ๋ฒ„ํ”„๋กœ๊ทธ๋ž˜๋ฐ #1 - IOCP๊ฒŒ์ž„์„œ๋ฒ„ํ”„๋กœ๊ทธ๋ž˜๋ฐ #1 - IOCP
๊ฒŒ์ž„์„œ๋ฒ„ํ”„๋กœ๊ทธ๋ž˜๋ฐ #1 - IOCP
Seungmo Koo
ย 
Overlapped IO์™€ IOCP ์กฐ์‚ฌ ๋ฐœํ‘œ
Overlapped IO์™€ IOCP ์กฐ์‚ฌ ๋ฐœํ‘œOverlapped IO์™€ IOCP ์กฐ์‚ฌ ๋ฐœํ‘œ
Overlapped IO์™€ IOCP ์กฐ์‚ฌ ๋ฐœํ‘œ
Kwen Won Lee
ย 
Asynchronous agents library(aal)pdf
Asynchronous agents library(aal)pdfAsynchronous agents library(aal)pdf
Asynchronous agents library(aal)pdf
HYUNWOO KIM
ย 
[OpenStack ํ•˜๋ฐ˜๊ธฐ ์Šคํ„ฐ๋””] Auto Install Kilo
[OpenStack ํ•˜๋ฐ˜๊ธฐ ์Šคํ„ฐ๋””] Auto Install Kilo[OpenStack ํ•˜๋ฐ˜๊ธฐ ์Šคํ„ฐ๋””] Auto Install Kilo
[OpenStack ํ•˜๋ฐ˜๊ธฐ ์Šคํ„ฐ๋””] Auto Install Kilo
OpenStack Korea Community
ย 
์ž˜ ์•Œ๋ ค์ง€์ง€ ์•Š์€ ์ˆจ์€ ์ง„์ฃผ, Winsock API - WSAPoll, Fast Loopback
์ž˜ ์•Œ๋ ค์ง€์ง€ ์•Š์€ ์ˆจ์€ ์ง„์ฃผ, Winsock API - WSAPoll, Fast Loopback์ž˜ ์•Œ๋ ค์ง€์ง€ ์•Š์€ ์ˆจ์€ ์ง„์ฃผ, Winsock API - WSAPoll, Fast Loopback
์ž˜ ์•Œ๋ ค์ง€์ง€ ์•Š์€ ์ˆจ์€ ์ง„์ฃผ, Winsock API - WSAPoll, Fast Loopback
ํฅ๋ฐฐ ์ตœ
ย 
์Šคํ†ฐ ๋ฏธ๋ฆฌ๋ณด๊ธฐ
์Šคํ†ฐ ๋ฏธ๋ฆฌ๋ณด๊ธฐ์Šคํ†ฐ ๋ฏธ๋ฆฌ๋ณด๊ธฐ
์Šคํ†ฐ ๋ฏธ๋ฆฌ๋ณด๊ธฐ
June Yi
ย 
[D2 CAMPUS] ์•ˆ๋“œ๋กœ์ด๋“œ ์˜คํ”ˆ์†Œ์Šค ์Šคํ„ฐ๋””์ž๋ฃŒ - Http Request
[D2 CAMPUS] ์•ˆ๋“œ๋กœ์ด๋“œ ์˜คํ”ˆ์†Œ์Šค ์Šคํ„ฐ๋””์ž๋ฃŒ - Http Request[D2 CAMPUS] ์•ˆ๋“œ๋กœ์ด๋“œ ์˜คํ”ˆ์†Œ์Šค ์Šคํ„ฐ๋””์ž๋ฃŒ - Http Request
[D2 CAMPUS] ์•ˆ๋“œ๋กœ์ด๋“œ ์˜คํ”ˆ์†Œ์Šค ์Šคํ„ฐ๋””์ž๋ฃŒ - Http Request
NAVER D2
ย 
Merge.c ์„ฑ๋Šฅ๊ฐœ์„ ๋ณด๊ณ ์„œ
Merge.c ์„ฑ๋Šฅ๊ฐœ์„ ๋ณด๊ณ ์„œMerge.c ์„ฑ๋Šฅ๊ฐœ์„ ๋ณด๊ณ ์„œ
Merge.c ์„ฑ๋Šฅ๊ฐœ์„ ๋ณด๊ณ ์„œ
Jung Eun Kim
ย 
bofแ„€แ…ตแ„Žแ…ฉ+rtl+fake_ebp
bofแ„€แ…ตแ„Žแ…ฉ+rtl+fake_ebpbofแ„€แ…ตแ„Žแ…ฉ+rtl+fake_ebp
bofแ„€แ…ตแ„Žแ…ฉ+rtl+fake_ebp
one_two_12
ย 
๋ณ‘๋ ฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ
๋ณ‘๋ ฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ๋ณ‘๋ ฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ
๋ณ‘๋ ฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ
์ค€ํ˜ ์ด
ย 
Gcd ppt
Gcd pptGcd ppt
Gcd ppt
Sangon Lee
ย 
Lock free queue
Lock free queueLock free queue
Lock free queue
Bongseok Cho
ย 
Buffer Overflow PPT (OneTwo)
Buffer Overflow PPT (OneTwo)Buffer Overflow PPT (OneTwo)
Buffer Overflow PPT (OneTwo)
one_two_12
ย 
Iocp ๊ธฐ๋ณธ ๊ตฌ์กฐ ์ดํ•ด
Iocp ๊ธฐ๋ณธ ๊ตฌ์กฐ ์ดํ•ดIocp ๊ธฐ๋ณธ ๊ตฌ์กฐ ์ดํ•ด
Iocp ๊ธฐ๋ณธ ๊ตฌ์กฐ ์ดํ•ด
Nam Hyeonuk
ย 

What's hot (20)

R2์„œ๋ฒ„์ •์ง„์šฑ
R2์„œ๋ฒ„์ •์ง„์šฑR2์„œ๋ฒ„์ •์ง„์šฑ
R2์„œ๋ฒ„์ •์ง„์šฑ
ย 
Optimizing merge program
Optimizing merge program Optimizing merge program
Optimizing merge program
ย 
Iocp advanced
Iocp advancedIocp advanced
Iocp advanced
ย 
Microsoft pp lpdf
Microsoft pp lpdfMicrosoft pp lpdf
Microsoft pp lpdf
ย 
PyCon 12์›” ์„ธ๋ฏธ๋‚˜ - ์‹ค์ „ ํŒŒ์ด์ฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ฑ… ํ™๋ณด
PyCon 12์›” ์„ธ๋ฏธ๋‚˜ - ์‹ค์ „ ํŒŒ์ด์ฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ฑ… ํ™๋ณดPyCon 12์›” ์„ธ๋ฏธ๋‚˜ - ์‹ค์ „ ํŒŒ์ด์ฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ฑ… ํ™๋ณด
PyCon 12์›” ์„ธ๋ฏธ๋‚˜ - ์‹ค์ „ ํŒŒ์ด์ฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ฑ… ํ™๋ณด
ย 
๊ฒŒ์ž„์„œ๋ฒ„ํ”„๋กœ๊ทธ๋ž˜๋ฐ #1 - IOCP
๊ฒŒ์ž„์„œ๋ฒ„ํ”„๋กœ๊ทธ๋ž˜๋ฐ #1 - IOCP๊ฒŒ์ž„์„œ๋ฒ„ํ”„๋กœ๊ทธ๋ž˜๋ฐ #1 - IOCP
๊ฒŒ์ž„์„œ๋ฒ„ํ”„๋กœ๊ทธ๋ž˜๋ฐ #1 - IOCP
ย 
Overlapped IO์™€ IOCP ์กฐ์‚ฌ ๋ฐœํ‘œ
Overlapped IO์™€ IOCP ์กฐ์‚ฌ ๋ฐœํ‘œOverlapped IO์™€ IOCP ์กฐ์‚ฌ ๋ฐœํ‘œ
Overlapped IO์™€ IOCP ์กฐ์‚ฌ ๋ฐœํ‘œ
ย 
Asynchronous agents library(aal)pdf
Asynchronous agents library(aal)pdfAsynchronous agents library(aal)pdf
Asynchronous agents library(aal)pdf
ย 
[OpenStack ํ•˜๋ฐ˜๊ธฐ ์Šคํ„ฐ๋””] Auto Install Kilo
[OpenStack ํ•˜๋ฐ˜๊ธฐ ์Šคํ„ฐ๋””] Auto Install Kilo[OpenStack ํ•˜๋ฐ˜๊ธฐ ์Šคํ„ฐ๋””] Auto Install Kilo
[OpenStack ํ•˜๋ฐ˜๊ธฐ ์Šคํ„ฐ๋””] Auto Install Kilo
ย 
์ž˜ ์•Œ๋ ค์ง€์ง€ ์•Š์€ ์ˆจ์€ ์ง„์ฃผ, Winsock API - WSAPoll, Fast Loopback
์ž˜ ์•Œ๋ ค์ง€์ง€ ์•Š์€ ์ˆจ์€ ์ง„์ฃผ, Winsock API - WSAPoll, Fast Loopback์ž˜ ์•Œ๋ ค์ง€์ง€ ์•Š์€ ์ˆจ์€ ์ง„์ฃผ, Winsock API - WSAPoll, Fast Loopback
์ž˜ ์•Œ๋ ค์ง€์ง€ ์•Š์€ ์ˆจ์€ ์ง„์ฃผ, Winsock API - WSAPoll, Fast Loopback
ย 
์Šคํ†ฐ ๋ฏธ๋ฆฌ๋ณด๊ธฐ
์Šคํ†ฐ ๋ฏธ๋ฆฌ๋ณด๊ธฐ์Šคํ†ฐ ๋ฏธ๋ฆฌ๋ณด๊ธฐ
์Šคํ†ฐ ๋ฏธ๋ฆฌ๋ณด๊ธฐ
ย 
NLog ์†Œ๊ฐœ
NLog ์†Œ๊ฐœNLog ์†Œ๊ฐœ
NLog ์†Œ๊ฐœ
ย 
[D2 CAMPUS] ์•ˆ๋“œ๋กœ์ด๋“œ ์˜คํ”ˆ์†Œ์Šค ์Šคํ„ฐ๋””์ž๋ฃŒ - Http Request
[D2 CAMPUS] ์•ˆ๋“œ๋กœ์ด๋“œ ์˜คํ”ˆ์†Œ์Šค ์Šคํ„ฐ๋””์ž๋ฃŒ - Http Request[D2 CAMPUS] ์•ˆ๋“œ๋กœ์ด๋“œ ์˜คํ”ˆ์†Œ์Šค ์Šคํ„ฐ๋””์ž๋ฃŒ - Http Request
[D2 CAMPUS] ์•ˆ๋“œ๋กœ์ด๋“œ ์˜คํ”ˆ์†Œ์Šค ์Šคํ„ฐ๋””์ž๋ฃŒ - Http Request
ย 
Merge.c ์„ฑ๋Šฅ๊ฐœ์„ ๋ณด๊ณ ์„œ
Merge.c ์„ฑ๋Šฅ๊ฐœ์„ ๋ณด๊ณ ์„œMerge.c ์„ฑ๋Šฅ๊ฐœ์„ ๋ณด๊ณ ์„œ
Merge.c ์„ฑ๋Šฅ๊ฐœ์„ ๋ณด๊ณ ์„œ
ย 
bofแ„€แ…ตแ„Žแ…ฉ+rtl+fake_ebp
bofแ„€แ…ตแ„Žแ…ฉ+rtl+fake_ebpbofแ„€แ…ตแ„Žแ…ฉ+rtl+fake_ebp
bofแ„€แ…ตแ„Žแ…ฉ+rtl+fake_ebp
ย 
๋ณ‘๋ ฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ
๋ณ‘๋ ฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ๋ณ‘๋ ฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ
๋ณ‘๋ ฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ
ย 
Gcd ppt
Gcd pptGcd ppt
Gcd ppt
ย 
Lock free queue
Lock free queueLock free queue
Lock free queue
ย 
Buffer Overflow PPT (OneTwo)
Buffer Overflow PPT (OneTwo)Buffer Overflow PPT (OneTwo)
Buffer Overflow PPT (OneTwo)
ย 
Iocp ๊ธฐ๋ณธ ๊ตฌ์กฐ ์ดํ•ด
Iocp ๊ธฐ๋ณธ ๊ตฌ์กฐ ์ดํ•ดIocp ๊ธฐ๋ณธ ๊ตฌ์กฐ ์ดํ•ด
Iocp ๊ธฐ๋ณธ ๊ตฌ์กฐ ์ดํ•ด
ย 

Similar to Asynchronous 101 (2)

18 2 แ„‘แ…กแ„‹แ…ตแ„Šแ…ฅแ†ซแ„‘แ…ญแ„Œแ…ฎแ†ซแ„…แ…กแ„‹แ…ตแ„‡แ…ณแ„…แ…ฅแ„…แ…ต
18 2 แ„‘แ…กแ„‹แ…ตแ„Šแ…ฅแ†ซแ„‘แ…ญแ„Œแ…ฎแ†ซแ„…แ…กแ„‹แ…ตแ„‡แ…ณแ„…แ…ฅแ„…แ…ต18 2 แ„‘แ…กแ„‹แ…ตแ„Šแ…ฅแ†ซแ„‘แ…ญแ„Œแ…ฎแ†ซแ„…แ…กแ„‹แ…ตแ„‡แ…ณแ„…แ…ฅแ„…แ…ต
18 2 แ„‘แ…กแ„‹แ…ตแ„Šแ…ฅแ†ซแ„‘แ…ญแ„Œแ…ฎแ†ซแ„…แ…กแ„‹แ…ตแ„‡แ…ณแ„…แ…ฅแ„…แ…ต
Changwon National University
ย 
14 2 iterator
14 2 iterator14 2 iterator
Effective c++ 1~8์žฅ
Effective c++ 1~8์žฅ Effective c++ 1~8์žฅ
Effective c++ 1~8์žฅ
Shin heemin
ย 
Api design for c++ ch3 pattern
Api design for c++ ch3 patternApi design for c++ ch3 pattern
Api design for c++ ch3 patternjinho park
ย 
GopherCon Korea 2015 - Python ๊ฐœ๋ฐœ์ž๋ฅผ ์œ„ํ•œ Go (์ด๊ฒฝ์ฐฌ)
GopherCon Korea 2015 - Python ๊ฐœ๋ฐœ์ž๋ฅผ ์œ„ํ•œ Go (์ด๊ฒฝ์ฐฌ)GopherCon Korea 2015 - Python ๊ฐœ๋ฐœ์ž๋ฅผ ์œ„ํ•œ Go (์ด๊ฒฝ์ฐฌ)
GopherCon Korea 2015 - Python ๊ฐœ๋ฐœ์ž๋ฅผ ์œ„ํ•œ Go (์ด๊ฒฝ์ฐฌ)
Kyoungchan Lee
ย 
effective c++ chapter 3~4 ์ •๋ฆฌ
effective c++ chapter 3~4 ์ •๋ฆฌeffective c++ chapter 3~4 ์ •๋ฆฌ
effective c++ chapter 3~4 ์ •๋ฆฌ
Injae Lee
ย 
Api design for c++ pattern
Api design for c++ patternApi design for c++ pattern
Api design for c++ pattern
jinho park
ย 
แ„‘แ…กแ„‹แ…ตแ„Šแ…ฅแ†ซ แ„‰แ…ณแ„แ…ฅแ„ƒแ…ต 9แ„Œแ…กแ†ผ
แ„‘แ…กแ„‹แ…ตแ„Šแ…ฅแ†ซ แ„‰แ…ณแ„แ…ฅแ„ƒแ…ต 9แ„Œแ…กแ†ผแ„‘แ…กแ„‹แ…ตแ„Šแ…ฅแ†ซ แ„‰แ…ณแ„แ…ฅแ„ƒแ…ต 9แ„Œแ…กแ†ผ
แ„‘แ…กแ„‹แ…ตแ„Šแ…ฅแ†ซ แ„‰แ…ณแ„แ…ฅแ„ƒแ…ต 9แ„Œแ…กแ†ผSeongHyun Ahn
ย 
Hoons ๋‹ท๋„ท ์ •๊ธฐ์„ธ๋ฏธ๋‚˜
Hoons ๋‹ท๋„ท ์ •๊ธฐ์„ธ๋ฏธ๋‚˜Hoons ๋‹ท๋„ท ์ •๊ธฐ์„ธ๋ฏธ๋‚˜
Hoons ๋‹ท๋„ท ์ •๊ธฐ์„ธ๋ฏธ๋‚˜
๋ณ‘๊ฑธ ์œค
ย 
Swift3 generic
Swift3 genericSwift3 generic
Swift3 generic
Eunjoo Im
ย 
C++ Advanced ๊ฐ•์˜ 4์ฃผ์ฐจ
 C++ Advanced ๊ฐ•์˜ 4์ฃผ์ฐจ C++ Advanced ๊ฐ•์˜ 4์ฃผ์ฐจ
C++ Advanced ๊ฐ•์˜ 4์ฃผ์ฐจ
HyunJoon Park
ย 
More effective c++ 3์ฃผ์ฐจ
More effective c++ 3์ฃผ์ฐจMore effective c++ 3์ฃผ์ฐจ
More effective c++ 3์ฃผ์ฐจInjae Lee
ย 
[์˜คํ”ˆ์†Œ์Šค์ปจ์„คํŒ…] ์Šค์นด์šฐํ„ฐ ์‚ฌ์šฉ์ž ๊ฐ€์ด๋“œ 2020
[์˜คํ”ˆ์†Œ์Šค์ปจ์„คํŒ…] ์Šค์นด์šฐํ„ฐ ์‚ฌ์šฉ์ž ๊ฐ€์ด๋“œ 2020[์˜คํ”ˆ์†Œ์Šค์ปจ์„คํŒ…] ์Šค์นด์šฐํ„ฐ ์‚ฌ์šฉ์ž ๊ฐ€์ด๋“œ 2020
[์˜คํ”ˆ์†Œ์Šค์ปจ์„คํŒ…] ์Šค์นด์šฐํ„ฐ ์‚ฌ์šฉ์ž ๊ฐ€์ด๋“œ 2020
Ji-Woong Choi
ย 
[๋„ค์ด๋ฒ„์˜คํ”ˆ์†Œ์Šค์„ธ๋ฏธ๋‚˜] Pinpoint๋ฅผ ์ด์šฉํ•ด์„œ ์„œ๋ฒ„๋ฆฌ์Šค ํ”Œ๋žซํผ Apache Openwhisk ํŠธ๋ ˆ์ด์‹ฑํ•˜๊ธฐ - ์˜ค์Šนํ˜„
[๋„ค์ด๋ฒ„์˜คํ”ˆ์†Œ์Šค์„ธ๋ฏธ๋‚˜] Pinpoint๋ฅผ ์ด์šฉํ•ด์„œ ์„œ๋ฒ„๋ฆฌ์Šค ํ”Œ๋žซํผ Apache Openwhisk ํŠธ๋ ˆ์ด์‹ฑํ•˜๊ธฐ - ์˜ค์Šนํ˜„[๋„ค์ด๋ฒ„์˜คํ”ˆ์†Œ์Šค์„ธ๋ฏธ๋‚˜] Pinpoint๋ฅผ ์ด์šฉํ•ด์„œ ์„œ๋ฒ„๋ฆฌ์Šค ํ”Œ๋žซํผ Apache Openwhisk ํŠธ๋ ˆ์ด์‹ฑํ•˜๊ธฐ - ์˜ค์Šนํ˜„
[๋„ค์ด๋ฒ„์˜คํ”ˆ์†Œ์Šค์„ธ๋ฏธ๋‚˜] Pinpoint๋ฅผ ์ด์šฉํ•ด์„œ ์„œ๋ฒ„๋ฆฌ์Šค ํ”Œ๋žซํผ Apache Openwhisk ํŠธ๋ ˆ์ด์‹ฑํ•˜๊ธฐ - ์˜ค์Šนํ˜„
NAVER Engineering
ย 
Javascript ์กฐ๊ธˆ ๋” ์ž˜ ์•Œ๊ธฐ
Javascript ์กฐ๊ธˆ ๋” ์ž˜ ์•Œ๊ธฐJavascript ์กฐ๊ธˆ ๋” ์ž˜ ์•Œ๊ธฐ
Javascript ์กฐ๊ธˆ ๋” ์ž˜ ์•Œ๊ธฐ
jongho jeong
ย 
์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ํ•จ์ˆ˜
์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ํ•จ์ˆ˜์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ํ•จ์ˆ˜
์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ํ•จ์ˆ˜์œ ์ง„ ๋ณ€
ย 

Similar to Asynchronous 101 (2) (20)

Effective c++ chapter 7,8
Effective c++ chapter 7,8Effective c++ chapter 7,8
Effective c++ chapter 7,8
ย 
18 2 แ„‘แ…กแ„‹แ…ตแ„Šแ…ฅแ†ซแ„‘แ…ญแ„Œแ…ฎแ†ซแ„…แ…กแ„‹แ…ตแ„‡แ…ณแ„…แ…ฅแ„…แ…ต
18 2 แ„‘แ…กแ„‹แ…ตแ„Šแ…ฅแ†ซแ„‘แ…ญแ„Œแ…ฎแ†ซแ„…แ…กแ„‹แ…ตแ„‡แ…ณแ„…แ…ฅแ„…แ…ต18 2 แ„‘แ…กแ„‹แ…ตแ„Šแ…ฅแ†ซแ„‘แ…ญแ„Œแ…ฎแ†ซแ„…แ…กแ„‹แ…ตแ„‡แ…ณแ„…แ…ฅแ„…แ…ต
18 2 แ„‘แ…กแ„‹แ…ตแ„Šแ…ฅแ†ซแ„‘แ…ญแ„Œแ…ฎแ†ซแ„…แ…กแ„‹แ…ตแ„‡แ…ณแ„…แ…ฅแ„…แ…ต
ย 
More effective c++ chapter1,2
More effective c++ chapter1,2More effective c++ chapter1,2
More effective c++ chapter1,2
ย 
14 2 iterator
14 2 iterator14 2 iterator
14 2 iterator
ย 
Effective c++ 1~8์žฅ
Effective c++ 1~8์žฅ Effective c++ 1~8์žฅ
Effective c++ 1~8์žฅ
ย 
Api design for c++ ch3 pattern
Api design for c++ ch3 patternApi design for c++ ch3 pattern
Api design for c++ ch3 pattern
ย 
GopherCon Korea 2015 - Python ๊ฐœ๋ฐœ์ž๋ฅผ ์œ„ํ•œ Go (์ด๊ฒฝ์ฐฌ)
GopherCon Korea 2015 - Python ๊ฐœ๋ฐœ์ž๋ฅผ ์œ„ํ•œ Go (์ด๊ฒฝ์ฐฌ)GopherCon Korea 2015 - Python ๊ฐœ๋ฐœ์ž๋ฅผ ์œ„ํ•œ Go (์ด๊ฒฝ์ฐฌ)
GopherCon Korea 2015 - Python ๊ฐœ๋ฐœ์ž๋ฅผ ์œ„ํ•œ Go (์ด๊ฒฝ์ฐฌ)
ย 
effective c++ chapter 3~4 ์ •๋ฆฌ
effective c++ chapter 3~4 ์ •๋ฆฌeffective c++ chapter 3~4 ์ •๋ฆฌ
effective c++ chapter 3~4 ์ •๋ฆฌ
ย 
Api design for c++ pattern
Api design for c++ patternApi design for c++ pattern
Api design for c++ pattern
ย 
แ„‘แ…กแ„‹แ…ตแ„Šแ…ฅแ†ซ แ„‰แ…ณแ„แ…ฅแ„ƒแ…ต 9แ„Œแ…กแ†ผ
แ„‘แ…กแ„‹แ…ตแ„Šแ…ฅแ†ซ แ„‰แ…ณแ„แ…ฅแ„ƒแ…ต 9แ„Œแ…กแ†ผแ„‘แ…กแ„‹แ…ตแ„Šแ…ฅแ†ซ แ„‰แ…ณแ„แ…ฅแ„ƒแ…ต 9แ„Œแ…กแ†ผ
แ„‘แ…กแ„‹แ…ตแ„Šแ…ฅแ†ซ แ„‰แ…ณแ„แ…ฅแ„ƒแ…ต 9แ„Œแ…กแ†ผ
ย 
Hoons ๋‹ท๋„ท ์ •๊ธฐ์„ธ๋ฏธ๋‚˜
Hoons ๋‹ท๋„ท ์ •๊ธฐ์„ธ๋ฏธ๋‚˜Hoons ๋‹ท๋„ท ์ •๊ธฐ์„ธ๋ฏธ๋‚˜
Hoons ๋‹ท๋„ท ์ •๊ธฐ์„ธ๋ฏธ๋‚˜
ย 
Swift3 generic
Swift3 genericSwift3 generic
Swift3 generic
ย 
C++ Advanced ๊ฐ•์˜ 4์ฃผ์ฐจ
 C++ Advanced ๊ฐ•์˜ 4์ฃผ์ฐจ C++ Advanced ๊ฐ•์˜ 4์ฃผ์ฐจ
C++ Advanced ๊ฐ•์˜ 4์ฃผ์ฐจ
ย 
More effective c++ 3์ฃผ์ฐจ
More effective c++ 3์ฃผ์ฐจMore effective c++ 3์ฃผ์ฐจ
More effective c++ 3์ฃผ์ฐจ
ย 
Effective c++(chapter 5,6)
Effective c++(chapter 5,6)Effective c++(chapter 5,6)
Effective c++(chapter 5,6)
ย 
[์˜คํ”ˆ์†Œ์Šค์ปจ์„คํŒ…] ์Šค์นด์šฐํ„ฐ ์‚ฌ์šฉ์ž ๊ฐ€์ด๋“œ 2020
[์˜คํ”ˆ์†Œ์Šค์ปจ์„คํŒ…] ์Šค์นด์šฐํ„ฐ ์‚ฌ์šฉ์ž ๊ฐ€์ด๋“œ 2020[์˜คํ”ˆ์†Œ์Šค์ปจ์„คํŒ…] ์Šค์นด์šฐํ„ฐ ์‚ฌ์šฉ์ž ๊ฐ€์ด๋“œ 2020
[์˜คํ”ˆ์†Œ์Šค์ปจ์„คํŒ…] ์Šค์นด์šฐํ„ฐ ์‚ฌ์šฉ์ž ๊ฐ€์ด๋“œ 2020
ย 
[๋„ค์ด๋ฒ„์˜คํ”ˆ์†Œ์Šค์„ธ๋ฏธ๋‚˜] Pinpoint๋ฅผ ์ด์šฉํ•ด์„œ ์„œ๋ฒ„๋ฆฌ์Šค ํ”Œ๋žซํผ Apache Openwhisk ํŠธ๋ ˆ์ด์‹ฑํ•˜๊ธฐ - ์˜ค์Šนํ˜„
[๋„ค์ด๋ฒ„์˜คํ”ˆ์†Œ์Šค์„ธ๋ฏธ๋‚˜] Pinpoint๋ฅผ ์ด์šฉํ•ด์„œ ์„œ๋ฒ„๋ฆฌ์Šค ํ”Œ๋žซํผ Apache Openwhisk ํŠธ๋ ˆ์ด์‹ฑํ•˜๊ธฐ - ์˜ค์Šนํ˜„[๋„ค์ด๋ฒ„์˜คํ”ˆ์†Œ์Šค์„ธ๋ฏธ๋‚˜] Pinpoint๋ฅผ ์ด์šฉํ•ด์„œ ์„œ๋ฒ„๋ฆฌ์Šค ํ”Œ๋žซํผ Apache Openwhisk ํŠธ๋ ˆ์ด์‹ฑํ•˜๊ธฐ - ์˜ค์Šนํ˜„
[๋„ค์ด๋ฒ„์˜คํ”ˆ์†Œ์Šค์„ธ๋ฏธ๋‚˜] Pinpoint๋ฅผ ์ด์šฉํ•ด์„œ ์„œ๋ฒ„๋ฆฌ์Šค ํ”Œ๋žซํผ Apache Openwhisk ํŠธ๋ ˆ์ด์‹ฑํ•˜๊ธฐ - ์˜ค์Šนํ˜„
ย 
More effective c++ 2
More effective c++ 2More effective c++ 2
More effective c++ 2
ย 
Javascript ์กฐ๊ธˆ ๋” ์ž˜ ์•Œ๊ธฐ
Javascript ์กฐ๊ธˆ ๋” ์ž˜ ์•Œ๊ธฐJavascript ์กฐ๊ธˆ ๋” ์ž˜ ์•Œ๊ธฐ
Javascript ์กฐ๊ธˆ ๋” ์ž˜ ์•Œ๊ธฐ
ย 
์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ํ•จ์ˆ˜
์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ํ•จ์ˆ˜์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ํ•จ์ˆ˜
์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ํ•จ์ˆ˜
ย 

Asynchronous 101 (2)

  • 1. ๋น„๋™๊ธฐ 101 Basic of Asynchronous ๋‘ ๋ฒˆ์งธ ์ด๋ฏผ์ฒ 
  • 2. ๋น„๋™๊ธฐ๋ฅผ ์œ„ํ•œ python ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋“ค.. โ€ข Tornado โ€ข call back ์Šคํƒ€์ผ์„ ์‚ฌ์šฉํ•˜๋Š” ๋น„๋™๊ธฐ ์›น ํ”„๋ ˆ์ž„ ์›Œํฌ โ€ข Gevent โ€ข Green thread ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” non blocking network I/O ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ โ€ข Twisted โ€ข Event-driven ๋ฐฉ์‹์˜ ๋น„๋™๊ธฐ network ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ
  • 3. callback โ€ข ๋น„๋™๊ธฐ ๋ฃจํ‹ด์ด ๋๋‚˜๋ฉด ์‹คํ–‰ํ•  ํ•จ์ˆ˜๋ฅผ ๊ฐ™์ด ๋„˜๊ฒจ์ค€๋‹ค โ‡’์ž‘์—…์ด ๋๋‚˜๋ฉด ํ•ด๋‹น ํ•จ์ˆ˜๋ฅผ ์‹คํ–‰ ํ•ด ์คŒ โ€ข โ€œ์ „ํ™”๋ฒˆํ˜ธ ๋‚จ๊ฒจ๋“œ๋ฆด ํ…Œ๋‹ˆ ์ผ ๋๋‚˜๋ฉด ์ „ํ™” ๋ถ€ํƒํ•ด์š”โ€
  • 5. callback โ€ข execute_washer -> execute_dryer -> fold_laundry โ‡’ execute_washer ํ•จ์ˆ˜ ์•ˆ์— execute_dryer์˜ ํ•ธ๋“ค๋Ÿฌ ํ•จ์ˆ˜ ์•ˆ์— fold_laundry ํ•ธ๋“ค๋Ÿฌ ํ•จ์ˆ˜๋ฅผ ์ž‘์„ฑ ํ•ด์•ผ ํ•จ โ€ข Callback chain์ด ๋” ๊ธธ์–ด์ง€๋ฉด? => ํ•จ์ˆ˜ ์•ˆ์— ์žˆ๋Š” callback ํ•จ์ˆ˜ ์•ˆ์— ์žˆ๋Š” callback ์•ˆ์— ์žˆ๋Š” callback ์•ˆ์— โ€ฆ
  • 7. Gevent and greed thread โ€ข Green thread: thread๋ฅผ os ๋‚˜ ํ•˜๋“œ์›จ์–ด๊ฐ€ ์ œ์–ดํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ software level ์—์„œ ์ง ์ ‘ ์ œ์–ดํ•œ๋‹ค. โ€ข ํšจ์œจ์ ์ด๊ณ  ์กฐ๊ธˆ ๋” ๋น ๋ฅธ thread ๊ฐ„์˜ context switching ์ด ๊ฐ€ ๋Šฅํ•˜๋‹ค. โ€ข Context switching ์˜ ์ด์ ์„ ๋นผ๋ฉด thread์˜ ๋ฌธ์ œ์ ์„ ๊ทธ๋Œ€๋กœ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค (๊ณต์œ  data ์ ‘๊ทผ ๋ฌธ์ œ ๋“ฑ..)
  • 8. Green thread VS callback Green thread โ€ข Thread๋“ค์ด ํ•˜๋“œ์›จ์–ด ๋Œ€์‹  application ๋ ˆ๋ฒจ์—์„œ ๊ด€๋ฆฌ๋œ๋‹ค โ€ข ์ผ๋ฐ˜ thread ์™€ ์œ ์‚ฌํ•จ: thread ๋ฅผ ์ดํ•ดํ•˜๊ณ  ์žˆ๋Š” ์‚ฌ๋žŒ์ด ์‚ฌ์šฉํ•˜๊ธฐ ์ข‹๋‹ค โ€ข Cpu context switching ๋ฌธ์ œ๋ฅผ ์ œ์™ธํ•œ ์ผ๋ฐ˜ thread programming ์ด ๊ฐ€์ง„ ๋ชจ๋“  ๋ฌธ์ œ์ ์„ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค Callback โ€ข Thread ํ”„๋กœ๊ทธ๋žจ๊ณผ ๋งŽ์€ ๋ถ€๋ถ„์ด ๋‹ค๋ฅด๋‹ค โ€ข ํ”„๋กœ๊ทธ๋ž˜๋จธ๋Š” thread์™€ ์ฝ”๋ฃจํ‹ด์„ ์ง์ ‘ ๋ณด๊ฑฐ๋‚˜ ์ œ์–ด ํ•  ์ˆ˜ ์—†๋‹ค โ€ข Callback์€ ์˜ˆ์™ธ๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค์ง€ ์•Š๋Š”๋‹ค โ€ข Callback์€ ์ˆ˜์ง‘ ํ•  ์ˆ˜ ์—†๋‹ค โ€ข Callback ์˜ callback์€ ๋ณต์žกํ•˜๋ฉฐ ๋””๋ฒ„๊น…์ด ์–ด๋ ต๋‹ค https://hackernoon.com/asynchronous-python-45df84b82434
  • 9. ์ด๊ฒŒ ์ตœ์„ ์ธ๊ฐ€์š” โ€ข ๋„ค. Python 3.3 (2012๋…„ ๋ฐœํ‘œ) ์ „ ๊นŒ์ง€๋Š”์š”
  • 10. ์ด๊ฒŒ ์ตœ์„ ์ธ๊ฐ€์š” โ€ข Python3.3 generator yield from ๋ฌธ๋ฒ• ์ง€์› โ€ข asyncio ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์˜(์ฝ”๋ฃจํ‹ด๊ณผ ๋น„๋™๊ธฐ event loop๋ฅผ ์ ๊ทน ํ™œ์šฉ) ๋ฐœ์ „ โ€ข Python3.4 asyncio ๋ฅผ ๋ฌด๋ ค built-in ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋กœ ์ œ๊ณต โ€ข Python3.5 async / await ๋ฌธ๋ฒ• ์ง€์›
  • 11. Iterable โ€ข ์ง์—ญํ•˜๋ฉด โ€˜๋ฐ˜๋ณต ๊ฐ€๋Šฅํ•œโ€™ โ€ข for loop์œผ๋กœ ์“ฐ์ผ ์ˆ˜ ์žˆ๋Š” ๋ชจ๋“  ๊ฐ์ฒด == iterable object โ€ข Ex: list, str, tuple โ€ฆ
  • 12. Iterator โ€ข next(iterator) ๋ฉ”์„œ๋“œ๋กœ ์ˆœ์ฐจ์ ์œผ๋กœ ๋ฐ์ดํ„ฐ ์ ‘๊ทผ โ€ข ๋ชจ๋“  ์š”์†Œ๋ฅผ ์ˆœํšŒํ–ˆ์œผ๋ฉด (๋” ์ด์ƒ์˜ ์š”์†Œ๊ฐ€ ์—†๋‹ค๋ฉด) next ํ˜ธ์ถœ์‹œ ์— StopIteration Exception ๋ฐœ์ƒ โ€ข Iterable object๋ฅผ for loop ์•ˆ์— ๋„ฃ์œผ๋ฉด python ๋‚ด๋ถ€์ ์œผ๋กœ iterator๋กœ ๋ณ€ํ™˜ ํ•˜์—ฌ ์ˆœํ™˜ํ•œ๋‹ค
  • 13. Iterator Iterable object ๋ฅผ iterator ๋กœ ๋ณ€ํ™˜
  • 15. Generator โ€ข ์กฐ๊ธˆ ๋” ์ง„๋ณด๋œ ํ˜•ํƒœ์˜ iterator โ€ข yield ํ‚ค์›Œ๋“œ๋ฅผ ํ†ตํ•ด ์™ธ๋ถ€๋กœ๋ถ€ํ„ฐ ๋ฐ์ดํ„ฐ๋ฅผ ์ž…๋ ฅ ๋ฐ›๊ฑฐ๋‚˜ ์™ธ๋ถ€๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์ถœ๋ ฅ ํ•  ์ˆ˜ ์žˆ๋‹ค โ€ข next(generator) ๋ฉ”์„œ๋“œ๋กœ ๋‹ค์Œ yield ์ถœ๋ ฅ ๊ฐ’ ๋ฆฌํ„ด
  • 16. Generator โ€ข ์กฐ๊ธˆ ๋” ์ง„๋ณด๋œ ํ˜•ํƒœ์˜ iterator (generator ์—ญ์‹œ for๋กœ ๋ฐ˜๋ณต๊ฐ€๋Šฅ) โ€ข yield ํ‚ค์›Œ๋“œ๋ฅผ ํ†ตํ•ด ์™ธ๋ถ€๋กœ๋ถ€ํ„ฐ ๋ฐ์ดํ„ฐ๋ฅผ ์ž…๋ ฅ ๋ฐ›๊ฑฐ๋‚˜ ์™ธ๋ถ€๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์ถœ๋ ฅ ํ•  ์ˆ˜ ์žˆ๋‹ค โ€ข next(generator) ๋ฉ”์„œ๋“œ๋กœ ๋‹ค์Œ yield ์ถœ๋ ฅ ๊ฐ’ ๋ฆฌํ„ด
  • 20. yield from โ€ข Generator ๋‚ด์—์„œ iterator, generator ์˜ ๋ชจ๋“  ์š”์†Œ๋ฅผ yield ํ•  ๋•Œ ์‚ฌ์šฉ โ€ข Generator๋ฅผ yield from ํ•  ๋•Œ๋Š” return ์„ ๋ฐ›์•„ ์˜ฌ ์ˆ˜ ์žˆ๋‹ค
  • 23. ์ฝ”๋ฃจํ‹ด โ€ข ๋ฃจํ‹ด์„ ์ง„ํ–‰ํ•˜๋Š” ์ค‘๊ฐ„์— ๋ฉˆ์ถ”์–ด์„œ ํŠน์ • ์œ„์น˜๋กœ ๋Œ์•„๊ฐ”๋‹ค๊ฐ€ ๋‹ค ์‹œ ์›๋ž˜ ์œ„์น˜๋กœ ๋Œ์•„์™€ ๋‚˜๋จธ์ง€ ๋ฃจํ‹ด์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ๋‹ค โ‡’์ง„์ž…์ ์ด ์—ฌ๋Ÿฌ ๊ฐœ์ธ ๋ฃจํ‹ด ์‹œ๊ฐ„ ์ค‘๋‹จ ์žฌ๊ฐœ Coroutine ์žฌ๊ฐœ์ค‘๋‹จ
  • 26. Python coroutine with async/await
  • 28. asyncio Event Loop โ€ข loop.run_until_complete โ€ข loop.run_forever โ€ข loop.call_soon โ€ข loop.stop โ€ข loop.run_in_executor
  • 30. asyncio document โ€ข https://docs.python.org/3.4/library/asyncio-task.html โ€ข https://docs.python.org/3/library/asyncio-eventloop.html