Skip to Content
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
Explore Skills
Cloud Computing
Microsoft Azure
Amazon Web Services (AWS)
Google Cloud
Cloud Migration
Cloud Deployment
Cloud Platforms
Data Engineering
Data Warehouse
SQL
Apache Spark
Microsoft SQL Server
MySQL
Kafka
Data Lake
Streaming & Messaging
NoSQL Databases
Relational Databases
Data Science
Pandas
R
MATLAB
SAS
D3
Power BI
Tableau
Statistics
Exploratory Data Analysis
Data Visualization
AI & ML
Generative AI
Machine Learning
Artificial Intelligence (AI)
Deep Learning
Reinforcement Learning
Natural Language Processing
TensorFlow
Scikit-Learn
Hyperparameter Tuning
MLOps
Programming Languages
Java
JavaScript
Spring
Python
Go
C#
C++
C
Swift
Rust
Functional Programming
Software Architecture
Object-Oriented
Distributed Systems
Domain-Driven Design
Architectural Patterns
IT/Ops
Kubernetes
Docker
GitHub
Terraform
Continuous Delivery
Continuous Integration
Database Administration
Computer Networking
Operating Systems
IT Certifications
Security
Network Security
Application Security
Incident Response
Zero Trust Model
Disaster Recovery
Penetration Testing / Ethical Hacking
Governance
Malware
Security Architecture
Security Engineering
Security Certifications
Design
Web Design
Graphic Design
Interaction Design
Film & Video
User Experience (UX)
Design Process
Design Tools
Business
Agile
Project Management
Product Management
Marketing
Human Resources
Finance
Team Management
Business Strategy
Digital Transformation
Organizational Leadership
Soft Skills
Professional Communication
Emotional Intelligence
Presentation Skills
Innovation
Critical Thinking
Public Speaking
Collaboration
Personal Productivity
Confidence / Motivation
Features
All features
Verifiable skills
AI Academy
Courses
Certifications
Interactive learning
Live events
Superstreams
Answers
Insights reporting
Radar Blog
Buy Courses
Plans
Sign In
Try Now
O'Reilly Platform
book
파이썬 비동기 라이브러리 Asyncio
by
동동구
,
케일럽 해팅
May 2021
Beginner to intermediate
176 pages
3h 37m
Korean
Hanbit Media, Inc.
Content preview from
파이썬 비동기 라이브러리 Asyncio
83
3
장
Asyncio 공략
② 이벤트 알림을 위해서는 네트워크 접속이 필요하므로, 별도의 비동기 태스크에서 호출을
수행한다. 이를 위해 여기서
create
_
task
()
함수를 사용한다.
하지만 이 코드에는 버그가 있다. 예제를 실행하고 연결이 살아있는 상태에서
Ctrl
-
C
로 서버
를 종료하면 다음과 같은 출력을 확인할 수 있다.
$
python telnetdemo.py
New connection.
^C
Connection dropped!
Bye!
Task was destroyed but it is pending!
task: <Task pending name='Task-6' coro=<send_event() done, ...>
왜 이런 일이 발생하는지 이해하기 위해, 종료 단계에서
asyncio
.
run
()
이 수행하는 정리
cleanup
절차를 다시 생각해봐야 한다. 특히 주의해야 할 부분은 바로
Ctrl
-
C
를 눌렀을 때
현재
진행 중인 모든 태스크를 수집하고 취소하는 부분이다. 이 부분 때문에
현재 진행 중인 태스크
들
만
await
하고, 그 태스크들에 대한
await
가 종료되면
asyncio
.
run
()
은 즉시 반환
return
한다.
수정된 코드의 버그는 ‘
echo
’ 태스크 취소 처리기
task
cancellation
handler
내의
새로운
태스크에서 발생
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
함수형 사고: 객체지향 개발자에서 함수형 개발자로 거듭나기
김재완, 닐 포드
코드로 인프라 관리하기(2판)
키프 모리스
파이썬 라이브러리를 활용한 텍스트 분석
젠스 알브레히트, 싯다르트 라마찬드란, 크리스티안 윙클러
Publisher Resources
ISBN: 9791162244197