파이썬[Python]: asyncio - run 함수

파이썬(Phthon): asyncio 모듈 - run 함수(function)


/// 설명

코루틴 coro를 시행하고 결과를 반환합니다.(asyncio 이벤트 루프 관리, 비동기 제너레이터 정리, 쓰레드 풀 종료 -> main으로 사용하여야 합니다.)
debug 인자가 True이면, 이벤트 루프는 디버그 방식으로 진행됩니다.

※ 형식
asyncio.run(coro, *, debug=False)

reference
https://docs.python.org/3/library/asyncio-task.html#asyncio.run

/// 예제

1
2
3
4
5
6
7
8
import asyncio
 
async def async_main():
    await asyncio.sleep(3)
    print('This is the first using asyncio.')  # This is the first using asyncio.
 
asyncio.run(async_main())
 
cs

* 실행환경: Microsoft Windows 10 Homes
* 인터프리터: 파이썬(Python 3.9)


– 당신을 응원합니다. –

댓글

이 블로그의 인기 게시물

파이썬[Python]: 내장함수 - from_bytes 메서드

파이썬[Python]: 내장함수 - __len__ 메서드

파이썬[Python]: kivy - 한글 사용

파이썬[Python]: 내장함수 - bit_length 메서드

C 언어: sin 함수, cos 함수, tan 함수