@@ -263,7 +263,6 @@ msgid "Close the transport."
263263msgstr "트랜스포트를 닫습니다."
264264
265265#: ../../library/asyncio-protocol.rst:154
266- #, fuzzy
267266msgid ""
268267"If the transport has a buffer for outgoing data, buffered data will be "
269268"flushed asynchronously. No more data will be received. After all "
@@ -274,7 +273,8 @@ msgid ""
274273msgstr ""
275274"트랜스포트에 송신 데이터용 버퍼가 있으면, 버퍼 된 데이터는 비동기적으로 플러시 됩니다. 더는 데이터가 수신되지 않습니다. 버퍼 된"
276275" 모든 데이터가 플러시 된 후, 프로토콜의 :meth:`protocol.connection_lost() "
277- "<BaseProtocol.connection_lost>` 메서드가 :const:`None`\\ 을 인자로 사용하여 호출됩니다."
276+ "<BaseProtocol.connection_lost>` 메서드가 :const:`None`\\ 을 인자로 사용하여 호출됩니다. "
277+ "트랜스포트가 닫힌 후에는 사용해서는 안 됩니다."
278278
279279#: ../../library/asyncio-protocol.rst:164
280280msgid "Return ``True`` if the transport is closing or is closed."
@@ -311,6 +311,9 @@ msgid ""
311311"if sock is not None:\n"
312312" print(sock.getsockopt(...))"
313313msgstr ""
314+ "sock = transport.get_extra_info('socket')\n"
315+ "if sock is not None:\n"
316+ " print(sock.getsockopt(...))"
314317
315318#: ../../library/asyncio-protocol.rst:186
316319msgid "Categories of information that can be queried on some transports:"
@@ -679,14 +682,13 @@ msgid "Stop the subprocess."
679682msgstr "서브 프로세스를 중지합니다."
680683
681684#: ../../library/asyncio-protocol.rst:425
682- #, fuzzy
683685msgid ""
684686"On POSIX systems, this method sends :py:const:`~signal.SIGTERM` to the "
685687"subprocess. On Windows, the Windows API function "
686688":c:func:`!TerminateProcess` is called to stop the subprocess."
687689msgstr ""
688- "POSIX 시스템에서, 이 메서드는 SIGTERM을 서브 프로세스로 보냅니다. 윈도에서, 서브 프로세스를 중지하기 위해 윈도우 "
689- "API 함수 TerminateProcess() 가 호출됩니다."
690+ "POSIX 시스템에서, 이 메서드는 :py:const:`~signal.SIGTERM` \\ 을 서브 프로세스로 보냅니다. 윈도에서, "
691+ "서브 프로세스를 중지하기 위해 윈도우 API 함수 :c:func:`! TerminateProcess` \\ 가 호출됩니다."
690692
691693#: ../../library/asyncio-protocol.rst:429
692694msgid "See also :meth:`subprocess.Popen.terminate`."
@@ -889,14 +891,14 @@ msgid ""
889891msgstr "이 메서드는 연결이 열려있는 동안 임의의 횟수만큼 호출될 수 있습니다."
890892
891893#: ../../library/asyncio-protocol.rst:561
892- #, fuzzy
893894msgid ""
894895"However, :meth:`protocol.eof_received() <Protocol.eof_received>` is "
895896"called at most once. Once ``eof_received()`` is called, "
896897"``data_received()`` is not called anymore."
897898msgstr ""
898899"그러나, :meth:`protocol.eof_received() <Protocol.eof_received>`\\ 는 최대한 한 번만 "
899- "호출됩니다. 일단 `eof_received()`\\ 가 호출되면, ``data_received()``\\ 는 더는 호출되지 않습니다."
900+ "호출됩니다. 일단 ``eof_received()``\\ 가 호출되면, ``data_received()``\\ 는 더는 호출되지 "
901+ "않습니다."
900902
901903#: ../../library/asyncio-protocol.rst:567
902904msgid ""
@@ -938,6 +940,10 @@ msgid ""
938940" [-> eof_received]?\n"
939941"-> connection_lost -> end"
940942msgstr ""
943+ "start -> connection_made\n"
944+ " [-> data_received]*\n"
945+ " [-> eof_received]?\n"
946+ "-> connection_lost -> end"
941947
942948#: ../../library/asyncio-protocol.rst:594
943949msgid "Buffered Streaming Protocols"
@@ -1024,6 +1030,12 @@ msgid ""
10241030" [-> eof_received]?\n"
10251031"-> connection_lost -> end"
10261032msgstr ""
1033+ "start -> connection_made\n"
1034+ " [-> get_buffer\n"
1035+ " [-> buffer_updated]?\n"
1036+ " ]*\n"
1037+ " [-> eof_received]?\n"
1038+ "-> connection_lost -> end"
10271039
10281040#: ../../library/asyncio-protocol.rst:654
10291041msgid "Datagram Protocols"
@@ -1088,7 +1100,6 @@ msgid "Subprocess Protocols"
10881100msgstr "서브 프로세스 프로토콜"
10891101
10901102#: ../../library/asyncio-protocol.rst:692
1091- #, fuzzy
10921103msgid ""
10931104"Subprocess Protocol instances should be constructed by protocol factories"
10941105" passed to the :meth:`loop.subprocess_exec` and "
@@ -1183,6 +1194,40 @@ msgid ""
11831194"\n"
11841195"asyncio.run(main())"
11851196msgstr ""
1197+ "import asyncio\n"
1198+ "\n"
1199+ "\n"
1200+ "class EchoServerProtocol(asyncio.Protocol):\n"
1201+ " def connection_made(self, transport):\n"
1202+ " peername = transport.get_extra_info('peername')\n"
1203+ " print('Connection from {}'.format(peername))\n"
1204+ " self.transport = transport\n"
1205+ "\n"
1206+ " def data_received(self, data):\n"
1207+ " message = data.decode()\n"
1208+ " print('Data received: {!r}'.format(message))\n"
1209+ "\n"
1210+ " print('Send: {!r}'.format(message))\n"
1211+ " self.transport.write(data)\n"
1212+ "\n"
1213+ " print('Close the client socket')\n"
1214+ " self.transport.close()\n"
1215+ "\n"
1216+ "\n"
1217+ "async def main():\n"
1218+ " # 저수준 API를 사용할 계획이므로\n"
1219+ " # 이벤트 루프에 대한 참조를 얻습니다.\n"
1220+ " loop = asyncio.get_running_loop()\n"
1221+ "\n"
1222+ " server = await loop.create_server(\n"
1223+ " EchoServerProtocol,\n"
1224+ " '127.0.0.1', 8888)\n"
1225+ "\n"
1226+ " async with server:\n"
1227+ " await server.serve_forever()\n"
1228+ "\n"
1229+ "\n"
1230+ "asyncio.run(main())"
11861231
11871232#: ../../library/asyncio-protocol.rst:769
11881233msgid ""
@@ -1250,6 +1295,47 @@ msgid ""
12501295"\n"
12511296"asyncio.run(main())"
12521297msgstr ""
1298+ "import asyncio\n"
1299+ "\n"
1300+ "\n"
1301+ "class EchoClientProtocol(asyncio.Protocol):\n"
1302+ " def __init__(self, message, on_con_lost):\n"
1303+ " self.message = message\n"
1304+ " self.on_con_lost = on_con_lost\n"
1305+ "\n"
1306+ " def connection_made(self, transport):\n"
1307+ " transport.write(self.message.encode())\n"
1308+ " print('Data sent: {!r}'.format(self.message))\n"
1309+ "\n"
1310+ " def data_received(self, data):\n"
1311+ " print('Data received: {!r}'.format(data.decode()))\n"
1312+ "\n"
1313+ " def connection_lost(self, exc):\n"
1314+ " print('The server closed the connection')\n"
1315+ " self.on_con_lost.set_result(True)\n"
1316+ "\n"
1317+ "\n"
1318+ "async def main():\n"
1319+ " # 저수준 API를 사용할 계획이므로\n"
1320+ " # 이벤트 루프에 대한 참조를 얻습니다.\n"
1321+ " loop = asyncio.get_running_loop()\n"
1322+ "\n"
1323+ " on_con_lost = loop.create_future()\n"
1324+ " message = 'Hello World!'\n"
1325+ "\n"
1326+ " transport, protocol = await loop.create_connection(\n"
1327+ " lambda: EchoClientProtocol(message, on_con_lost),\n"
1328+ " '127.0.0.1', 8888)\n"
1329+ "\n"
1330+ " # 프로토콜이 연결이 끊어졌음을 알릴 때까지 기다리고\n"
1331+ " # 트랜스포트를 닫습니다.\n"
1332+ " try:\n"
1333+ " await on_con_lost\n"
1334+ " finally:\n"
1335+ " transport.close()\n"
1336+ "\n"
1337+ "\n"
1338+ "asyncio.run(main())"
12531339
12541340#: ../../library/asyncio-protocol.rst:825
12551341msgid ""
@@ -1310,6 +1396,40 @@ msgid ""
13101396"\n"
13111397"asyncio.run(main())"
13121398msgstr ""
1399+ "import asyncio\n"
1400+ "\n"
1401+ "\n"
1402+ "class EchoServerProtocol:\n"
1403+ " def connection_made(self, transport):\n"
1404+ " self.transport = transport\n"
1405+ "\n"
1406+ " def datagram_received(self, data, addr):\n"
1407+ " message = data.decode()\n"
1408+ " print('Received %r from %s' % (message, addr))\n"
1409+ " print('Send %r to %s' % (message, addr))\n"
1410+ " self.transport.sendto(data, addr)\n"
1411+ "\n"
1412+ "\n"
1413+ "async def main():\n"
1414+ " print(\" Starting UDP server\" )\n"
1415+ "\n"
1416+ " # 저수준 API를 사용할 계획이므로\n"
1417+ " # 이벤트 루프에 대한 참조를 얻습니다.\n"
1418+ " loop = asyncio.get_running_loop()\n"
1419+ "\n"
1420+ " # 모든 클라이언트 요청을 처리할\n"
1421+ " # 하나의 프로토콜 인스턴스가 만들어집니다.\n"
1422+ " transport, protocol = await loop.create_datagram_endpoint(\n"
1423+ " EchoServerProtocol,\n"
1424+ " local_addr=('127.0.0.1', 9999))\n"
1425+ "\n"
1426+ " try:\n"
1427+ " await asyncio.sleep(3600) # 1시간 동안 서비스합니다.\n"
1428+ " finally:\n"
1429+ " transport.close()\n"
1430+ "\n"
1431+ "\n"
1432+ "asyncio.run(main())"
13131433
13141434#: ../../library/asyncio-protocol.rst:876
13151435msgid "UDP Echo Client"
@@ -1373,6 +1493,53 @@ msgid ""
13731493"\n"
13741494"asyncio.run(main())"
13751495msgstr ""
1496+ "import asyncio\n"
1497+ "\n"
1498+ "\n"
1499+ "class EchoClientProtocol:\n"
1500+ " def __init__(self, message, on_con_lost):\n"
1501+ " self.message = message\n"
1502+ " self.on_con_lost = on_con_lost\n"
1503+ " self.transport = None\n"
1504+ "\n"
1505+ " def connection_made(self, transport):\n"
1506+ " self.transport = transport\n"
1507+ " print('Send:', self.message)\n"
1508+ " self.transport.sendto(self.message.encode())\n"
1509+ "\n"
1510+ " def datagram_received(self, data, addr):\n"
1511+ " print(\" Received:\" , data.decode())\n"
1512+ "\n"
1513+ " print(\" Close the socket\" )\n"
1514+ " self.transport.close()\n"
1515+ "\n"
1516+ " def error_received(self, exc):\n"
1517+ " print('Error received:', exc)\n"
1518+ "\n"
1519+ " def connection_lost(self, exc):\n"
1520+ " print(\" Connection closed\" )\n"
1521+ " self.on_con_lost.set_result(True)\n"
1522+ "\n"
1523+ "\n"
1524+ "async def main():\n"
1525+ " # 저수준 API를 사용할 계획이므로\n"
1526+ " # 이벤트 루프에 대한 참조를 얻습니다.\n"
1527+ " loop = asyncio.get_running_loop()\n"
1528+ "\n"
1529+ " on_con_lost = loop.create_future()\n"
1530+ " message = \" Hello World!\" \n"
1531+ "\n"
1532+ " transport, protocol = await loop.create_datagram_endpoint(\n"
1533+ " lambda: EchoClientProtocol(message, on_con_lost),\n"
1534+ " remote_addr=('127.0.0.1', 9999))\n"
1535+ "\n"
1536+ " try:\n"
1537+ " await on_con_lost\n"
1538+ " finally:\n"
1539+ " transport.close()\n"
1540+ "\n"
1541+ "\n"
1542+ "asyncio.run(main())"
13761543
13771544#: ../../library/asyncio-protocol.rst:933
13781545msgid "Connecting Existing Sockets"
@@ -1435,6 +1602,54 @@ msgid ""
14351602"\n"
14361603"asyncio.run(main())"
14371604msgstr ""
1605+ "import asyncio\n"
1606+ "import socket\n"
1607+ "\n"
1608+ "\n"
1609+ "class MyProtocol(asyncio.Protocol):\n"
1610+ "\n"
1611+ " def __init__(self, on_con_lost):\n"
1612+ " self.transport = None\n"
1613+ " self.on_con_lost = on_con_lost\n"
1614+ "\n"
1615+ " def connection_made(self, transport):\n"
1616+ " self.transport = transport\n"
1617+ "\n"
1618+ " def data_received(self, data):\n"
1619+ " print(\" Received:\" , data.decode())\n"
1620+ "\n"
1621+ " # 작업을 완료했습니다: 트랜스포트를 닫습니다;\n"
1622+ " # connection_lost()가 자동으로 호출됩니다.\n"
1623+ " self.transport.close()\n"
1624+ "\n"
1625+ " def connection_lost(self, exc):\n"
1626+ " # 소켓이 닫혔습니다\n"
1627+ " self.on_con_lost.set_result(True)\n"
1628+ "\n"
1629+ "\n"
1630+ "async def main():\n"
1631+ " # 저수준 API를 사용할 계획이므로\n"
1632+ " # 이벤트 루프에 대한 참조를 얻습니다.\n"
1633+ " loop = asyncio.get_running_loop()\n"
1634+ " on_con_lost = loop.create_future()\n"
1635+ "\n"
1636+ " # 연결된 소켓 쌍을 만듭니다\n"
1637+ " rsock, wsock = socket.socketpair()\n"
1638+ "\n"
1639+ " # 데이터를 기다릴 소켓을 등록합니다.\n"
1640+ " transport, protocol = await loop.create_connection(\n"
1641+ " lambda: MyProtocol(on_con_lost), sock=rsock)\n"
1642+ "\n"
1643+ " # 네트워크로부터의 데이터 수신을 흉내 냅니다.\n"
1644+ " loop.call_soon(wsock.send, 'abc'.encode())\n"
1645+ "\n"
1646+ " try:\n"
1647+ " await protocol.on_con_lost\n"
1648+ " finally:\n"
1649+ " transport.close()\n"
1650+ " wsock.close()\n"
1651+ "\n"
1652+ "asyncio.run(main())"
14381653
14391654#: ../../library/asyncio-protocol.rst:989
14401655msgid ""
@@ -1529,6 +1744,63 @@ msgid ""
15291744"date = asyncio.run(get_date())\n"
15301745"print(f\" Current date: {date}\" )"
15311746msgstr ""
1747+ "import asyncio\n"
1748+ "import sys\n"
1749+ "\n"
1750+ "class DateProtocol(asyncio.SubprocessProtocol):\n"
1751+ " def __init__(self, exit_future):\n"
1752+ " self.exit_future = exit_future\n"
1753+ " self.output = bytearray()\n"
1754+ " self.pipe_closed = False\n"
1755+ " self.exited = False\n"
1756+ "\n"
1757+ " def pipe_connection_lost(self, fd, exc):\n"
1758+ " self.pipe_closed = True\n"
1759+ " self.check_for_exit()\n"
1760+ "\n"
1761+ " def pipe_data_received(self, fd, data):\n"
1762+ " self.output.extend(data)\n"
1763+ "\n"
1764+ " def process_exited(self):\n"
1765+ " self.exited = True\n"
1766+ " # pipe_connection_lost() 메서드 전에\n"
1767+ " # process_exited() 메서드가 호출될 수 있습니다:\n"
1768+ " # 두 메서드가 모두 호출될 때까지 기다립니다.\n"
1769+ " self.check_for_exit()\n"
1770+ "\n"
1771+ " def check_for_exit(self):\n"
1772+ " if self.pipe_closed and self.exited:\n"
1773+ " self.exit_future.set_result(True)\n"
1774+ "\n"
1775+ "async def get_date():\n"
1776+ " # 저수준 API를 사용할 계획이므로\n"
1777+ " # 이벤트 루프에 대한 참조를 얻습니다.\n"
1778+ " loop = asyncio.get_running_loop()\n"
1779+ "\n"
1780+ " code = 'import datetime; print(datetime.datetime.now())'\n"
1781+ " exit_future = asyncio.Future(loop=loop)\n"
1782+ "\n"
1783+ " # DateProtocol이 제어하는 서브 프로세스를 만듭니다;\n"
1784+ " # 표준 출력을 파이프로 리디렉트합니다.\n"
1785+ " transport, protocol = await loop.subprocess_exec(\n"
1786+ " lambda: DateProtocol(exit_future),\n"
1787+ " sys.executable, '-c', code,\n"
1788+ " stdin=None, stderr=None)\n"
1789+ "\n"
1790+ " # 프로토콜의 process_exited() 메서드를 사용하여\n"
1791+ " # 서브 프로세스 종료를 기다립니다.\n"
1792+ " await exit_future\n"
1793+ "\n"
1794+ " # stdout 파이프를 닫습니다.\n"
1795+ " transport.close()\n"
1796+ "\n"
1797+ " # 프로토콜의 pipe_data_received() 메서드로\n"
1798+ " # 수집된 출력을 읽습니다.\n"
1799+ " data = bytes(protocol.output)\n"
1800+ " return data.decode('ascii').rstrip()\n"
1801+ "\n"
1802+ "date = asyncio.run(get_date())\n"
1803+ "print(f\" Current date: {date}\" )"
15321804
15331805#: ../../library/asyncio-protocol.rst:1065
15341806msgid ""
0 commit comments