로딩
티스토리 데이터 처리 중입니다.

[Python] Concurrency Thread Decorator - 3

 [Python] Concurrency Thread Decorator - 3

[Python] Concurrency Thread Decorator Thread Decorator 정말로 간단한 함수들을 Thread를 사용하기 위해 계속 같은 코드를 구현하는 것을 피곤하다. 다행히도 Python은 Decorator 기능이 있다.

Decorator기능을 활용해서 간단한 비동기 I/O 함수들은 Thread로 동작하도록 하자. HTTP Reqeust는 Thread 보다는 async await를 활용한 Coroutine으로 작성하고 안에는 꼭 비동기를 지원하는 패키지를 사용하자. def using_thread(func: Callable): def decorator(*args): th = Thread(target=func, args=(*args,)) th.start() return th ret.....