Skip to Content
전문가를 위한 파이썬(2판)
book

전문가를 위한 파이썬(2판)

by 루시아누 하말류, 강권학
November 2024
Beginner to intermediate
1064 pages
25h 21m
Korean
Hanbit Media, Inc.
Content preview from 전문가를 위한 파이썬(2판)
898
4
제어 흐름
데, 이 코루틴은 네트워크에서 데이터를 보내거나 받으려고 기다려야 할 때마다 제어권을 다시
이벤트 루프로 돌려준다.
이벤트 루프가 살아있는 동안에는 서버에 연결하는 클라이언트마다
finder( )
코루틴의 새로
운 인스턴스가 실행된다. 이렇게 함으로써 이 간단한 서버가 여러 클라이언트를 동시에 처리할
수 있게 된다. 이 과정은 서버에서
KeyboardInterrupt
예외가 발생하거나
OS
가 서버 프로세
스를 종료할 때까지 계속된다.
이제
finder( )
코루틴이 있는
tcp_mojifinder.py
의 앞부분을 살펴보자.
예제
21-14
tcp
_
mojifinder
.
py
: [예제
21
-
12
]에서 이어짐
import asyncio
import functools
import sys
from asyncio.trsock import TransportSocket
from typing import cast
from charindex import InvertedIndex, format_results ❶
CRLF = b’\r\n’
PROMPT = b’?> ‘
async def finder(index: InvertedIndex, ❷
reader: asyncio.StreamReader,
writer: asyncio.StreamWriter) -> None:
client ...
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

전문가를 위한 리액트

전문가를 위한 리액트

테자스 쿠마르
고성능 파이썬(2판)

고성능 파이썬(2판)

오현석, 미샤 고렐릭, 이안 오스발트

Publisher Resources

ISBN: 9791169211772