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

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

by 동동구, 케일럽 해팅
May 2021
Beginner to intermediate
176 pages
3h 37m
Korean
Hanbit Media, Inc.
Content preview from 파이썬 비동기 라이브러리 Asyncio
43
3
Asyncio 공략
레드 기반 방식 (
ThreadPoolExecutor
)이지만 프로세스 기반 방식(
ProcessPoolExecutor
)
사용할 수도 있다. [예제
3
-
2
]에서 익스큐터에 대한 설명은 생략하였는데 이는 설명을 모호하게
할 수 있기 때문이다. 이제 기본적인 설명을 마무리했으므로 익스큐터에 대해 설명하겠다.
몇 가지 특이한 부분을 알아두어야 한다. [예제
3
-
3
]를 살펴보자.
예제
3-3
기본 익스큐터 인터페이스
# quickstart_exe.py
import time
import asyncio
async def main():
print(f'{time.ctime()} Hello!')
await asyncio.sleep(1.0)
print(f'{time.ctime()} Goodbye!')
def blocking(): #①
time.sleep(0.5) #②
print(f"{time.ctime()} Hello from a thread!")
loop = asyncio.get_event_loop()
task = loop.create_task(main())
loop.run_in_executor(None, blocking) #③
loop.run_until_complete(task)
pending = asyncio.all_tasks(loop=loop) ...
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