@@ -71,9 +71,8 @@ msgstr ""
71
71
"메서드를 호출하여 얻을 수 있습니다."
72
72
73
73
#: ../../library/asyncio-queue.rst:39
74
- #, fuzzy
75
74
msgid "Removed the *loop* parameter."
76
- msgstr "*loop* 매개 변수 "
75
+ msgstr "*loop* 매개 변수를 제거했습니다. "
77
76
78
77
#: ../../library/asyncio-queue.rst:43
79
78
msgid "This class is :ref:`not thread safe <asyncio-multithreading>`."
@@ -92,12 +91,11 @@ msgid "Return ``True`` if there are :attr:`maxsize` items in the queue."
92
91
msgstr "큐에 :attr:`maxsize` 항목이 있으면 ``True``\\ 를 반환합니다."
93
92
94
93
#: ../../library/asyncio-queue.rst:57
95
- #, fuzzy
96
94
msgid ""
97
95
"If the queue was initialized with ``maxsize=0`` (the default), then "
98
96
":meth:`full` never returns ``True``."
99
97
msgstr ""
100
- "큐가 ``maxsize=0`` (기본값)으로 초기화되었으면, :meth:`full() `\\ 은 절대 ``True``\\ 를 반환하지 "
98
+ "큐가 ``maxsize=0`` (기본값)으로 초기화되었으면, :meth:`full`\\ 은 절대 ``True``\\ 를 반환하지 "
101
99
"않습니다."
102
100
103
101
#: ../../library/asyncio-queue.rst:63
@@ -178,19 +176,17 @@ msgid ""
178
176
msgstr ""
179
177
180
178
#: ../../library/asyncio-queue.rst:121
181
- #, fuzzy
182
179
msgid "Indicate that a formerly enqueued work item is complete."
183
- msgstr "이전에 큐에 넣은 작업이 완료되었음을 나타냅니다."
180
+ msgstr "이전에 큐에 넣은 작업 항목이 완료되었음을 나타냅니다."
184
181
185
182
#: ../../library/asyncio-queue.rst:123
186
- #, fuzzy
187
183
msgid ""
188
184
"Used by queue consumers. For each :meth:`~Queue.get` used to fetch a work"
189
185
" item, a subsequent call to :meth:`task_done` tells the queue that the "
190
186
"processing on the work item is complete."
191
187
msgstr ""
192
- "큐 소비자가 사용합니다. 작업을 꺼내는 데 사용된 :meth:`~Queue.get` 마다, 뒤따르는 :meth:`task_done` "
193
- " 호출은 작업에 관한 처리가 완료되었음을 큐에 알려줍니다."
188
+ "큐 소비자가 사용합니다. 작업 항목을 꺼내는 데 사용된 :meth:`~Queue.get` 마다, 뒤따르는 "
189
+ ":meth:`task_done` 호출은 작업 항목에 관한 처리가 완료되었음을 큐에 알려줍니다."
194
190
195
191
#: ../../library/asyncio-queue.rst:127
196
192
msgid ""
@@ -254,11 +250,10 @@ msgid ""
254
250
msgstr ":meth:`~Queue.put_nowait` 메서드가 *maxsize*\\ 에 도달한 큐에 호출될 때 발생하는 예외입니다."
255
251
256
252
#: ../../library/asyncio-queue.rst:177
257
- #, fuzzy
258
253
msgid ""
259
254
"Exception raised when :meth:`~Queue.put` or :meth:`~Queue.get` is called "
260
255
"on a queue which has been shut down."
261
- msgstr ":meth:`~Queue.put_nowait` 메서드가 *maxsize* \\ 에 도달한 큐에 호출될 때 발생하는 예외입니다."
256
+ msgstr ":meth:`~Queue.put` 이나 :meth:`~Queue.get` 메서드가 종료된 큐에 호출될 때 발생하는 예외입니다."
262
257
263
258
#: ../../library/asyncio-queue.rst:184
264
259
msgid "Examples"
@@ -328,4 +323,58 @@ msgid ""
328
323
"\n"
329
324
"asyncio.run(main())"
330
325
msgstr ""
326
+ "import asyncio\n"
327
+ "import random\n"
328
+ "import time\n"
329
+ "\n"
330
+ "\n"
331
+ "async def worker(name, queue):\n"
332
+ " while True:\n"
333
+ " # 큐에서 \" 작업 항목\" 을 가져옵니다.\n"
334
+ " sleep_for = await queue.get()\n"
335
+ "\n"
336
+ " # \" sleep_for\" 초 동안 잡니다.\n"
337
+ " await asyncio.sleep(sleep_for)\n"
338
+ "\n"
339
+ " # 큐에 \" 작업 항목\" 이 처리되었음을 알립니다.\n"
340
+ " queue.task_done()\n"
341
+ "\n"
342
+ " print(f'{name} has slept for {sleep_for:.2f} seconds')\n"
343
+ "\n"
344
+ "\n"
345
+ "async def main():\n"
346
+ " # \" 작업 부하\" 를 저장하는 데 사용할 큐를 만듭니다.\n"
347
+ " queue = asyncio.Queue()\n"
348
+ "\n"
349
+ " # 무작위 대기 시간을 만들어서 큐에 넣습니다.\n"
350
+ " total_sleep_time = 0\n"
351
+ " for _ in range(20):\n"
352
+ " sleep_for = random.uniform(0.05, 1.0)\n"
353
+ " total_sleep_time += sleep_for\n"
354
+ " queue.put_nowait(sleep_for)\n"
355
+ "\n"
356
+ " # 큐를 동시에 처리할 세 개의 worker 태스크를 만듭니다.\n"
357
+ " tasks = []\n"
358
+ " for i in range(3):\n"
359
+ " task = asyncio.create_task(worker(f'worker-{i}', queue))\n"
360
+ " tasks.append(task)\n"
361
+ "\n"
362
+ " # 큐가 완전히 처리될 때까지 기다립니다.\n"
363
+ " started_at = time.monotonic()\n"
364
+ " await queue.join()\n"
365
+ " total_slept_for = time.monotonic() - started_at\n"
366
+ "\n"
367
+ " # worker 태스크를 취소합니다.\n"
368
+ " for task in tasks:\n"
369
+ " task.cancel()\n"
370
+ " # 모든 worker 태스크가 취소될 때까지 기다립니다.\n"
371
+ " await asyncio.gather(*tasks, return_exceptions=True)\n"
372
+ "\n"
373
+ " print('====')\n"
374
+ " print(f'3 workers slept in parallel for {total_slept_for:.2f} "
375
+ "seconds')\n"
376
+ " print(f'total expected sleep time: {total_sleep_time:.2f} seconds')\n"
377
+ "\n"
378
+ "\n"
379
+ "asyncio.run(main())"
331
380
0 commit comments