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

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

by 동동구, 케일럽 해팅
May 2021
Beginner to intermediate
176 pages
3h 37m
Korean
Hanbit Media, Inc.
Content preview from 파이썬 비동기 라이브러리 Asyncio
173
부록
B
보충 자료
B.5
Sanic
예제를 위한 보충 자료:
aelapsed
aprofiler
4
장의
Sanic
사례 연구에서 함수 실행에 소요된 시간을 출력하는 데커레이터를 사용했었다.
[예제
B
-
5
]에서 확인할 수 있다.
예제
B-5
perf
.
py
# perf.py
import logging
from time import perf_counter
from inspect import iscoroutinefunction
logger = logging.getLogger('perf')
def aelapsed(corofn, caption=''): #①
async def wrapper(*args, **kwargs):
t0 = perf_counter()
result = await corofn(*args, **kwargs)
delta = (perf_counter() - t0) * 1e3
logger.info(
f'{caption} Elapsed: {delta:.2f} ms')
return result
return wrapper
def aprofiler(cls, bases, members): #②
for k, v in members.items():
if iscoroutinefunction(v):
members[k] = aelapsed(v, ...
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