Skip to Content
파이썬 비동기 라이브러리 Asyncio
book

파이썬 비동기 라이브러리 Asyncio

by 동동구, 케일럽 해팅
May 2021
Beginner to intermediate
176 pages
3h 37m
Korean
Hanbit Media, Inc.
Content preview from 파이썬 비동기 라이브러리 Asyncio
71
3
Asyncio 공략
다)는 호출이 완료될 때까지 대기하지 않을 것이다.
비동기 콘텍스트 관리자는 많은
asyncio
기반 코드에서 사용되므로, 깊이 이해하고 있어야 한
다. 새로운
@
asynccontextmanager
데커레이터에 대한 더 상세한 정보를 파이썬
3
.
7
문서
29
에서 확인할 수 있다.
3.7
비동기 이터레이터
async
for
다음으로
for
루프의 비동기 버전을 살펴보자. 파이썬 언어의 다른 기능들과 마찬가지로, 반복
iteration
특별 메서드
(이름에
2
개의 밑줄
underscore
을 포함한다 )를 통해 구현되어 있다는 점을 이
해하면 비동기 버전도 쉽게 이해할 수 있다.
참고 삼아, [예제
3
-
24
]에서 일반적 (동기 ) 이터레이터를
__
iter
__()
__
next
__()
메서드
로 정의하였다.
예제
3-24
비동기 아닌 전통적인 이터레이터
>>> class A:
... def __iter__(self): #①
... self.x = 0 #②
... return self #③
... def __next__(self): #④
... if self.x > 2:
... raise StopIteration #⑤
... else:
... self.x += 1
... return self.x #⑥
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

프로그래머의 길 멘토에게 묻다

프로그래머의 길 멘토에게 묻다

David Hoover, Adewale Oshineye, Kang Jung Bin
파이썬 라이브러리를 활용한 텍스트 분석

파이썬 라이브러리를 활용한 텍스트 분석

젠스 알브레히트, 싯다르트 라마찬드란, 크리스티안 윙클러

Publisher Resources

ISBN: 9791162244197