Python 2에서 pull 큐 사용
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
이 페이지는 App Engine 표준 환경의 pull 큐를 간단히 소개합니다.
push 큐 태스크는 큐의 구성에 따라 작업자 서비스로 전달됩니다. Pull 큐에서는 작업자 서비스가 큐에 작업을 요청해야 합니다. 큐는 작업자가 특정 기간 동안 태스크를 처리하도록 고유한 액세스를 허용하여 응답하며, 이를 임대라고 합니다.

또한 pull 큐를 사용하면 관련된 태스크를 태그로 그룹화하고 작업자가 특정 태그가 있는 여러 태스크를 한 번에 가져오도록 구성할 수 있습니다. 이 프로세스를 일괄 처리라고 합니다.
작업자가 임대 만료 전에 태스크를 처리할 수 없는 경우, 임대를 갱신하거나 그대로 만료시킬 수 있으며, 임대가 만료되면 다른 작업자가 태스크를 획득할 수 있습니다. 태스크와 관련된 처리가 완료되면 작업자는 태스크를 삭제해야 합니다.
Pull 큐를 사용하려면 push 큐에서 자동화되는 일부 기능을 처리하는 코드가 있어야 합니다.
- 작업자 조정
- 코드에서는 처리량을 토대로 작업자 수가 조정되어야 합니다. 코드에서 조정이 처리되지 않는 경우 처리할 태스크가 없으면 컴퓨팅 리소스가 낭비될 수 있습니다. 또한 처리할 태스크가 너무 많으면 지연 시간이 발생할 수 있습니다.
- 태스크 삭제
- 또한 코드에서 처리된 태스크가 명시적으로 삭제되어야 합니다.
push 큐에서는 App Engine이 자동으로 태스크를 삭제합니다. 작업자가 pull 큐 태스크를 처리한 후에 삭제하지 않으면 다른 작업자가 태스크를 다시 처리합니다. 따라서 컴퓨팅 리소스가 낭비되며 태스크에 멱등성이 없는 경우 오류가 발생합니다.
queue.yaml
이라는 구성 파일에 속성을 설정하면 App Engine 표준 환경에서 pull 큐가 생성됩니다.
pull 큐 워크플로
pull 큐의 태스크를 처리하는 작업자는 App Engine 표준 환경에서 실행되는 서비스 내에 정의되어야 합니다.
워크플로는 다음과 같습니다.
queue.yaml
을 사용하여 pull 큐를 만듭니다.
- 태스크를 만들고 큐에 추가합니다.
- 생성된 작업자가 TaskQueue를 사용하여 태스크를 임대합니다.
- App Engine이 임대 응답을 통해 작업자에게 태스크 데이터를 보냅니다.
- 작업자가 태스크를 처리합니다. 임대가 만료되기 전에 태스크를 실행할 수 없으면 작업자는 임대 기간을 수정할 수 있습니다. 임대가 만료되면 태스크는 다른 작업자에게 임대될 수 있습니다.
- 태스크가 성공적으로 처리되면 작업자가 태스크를 삭제합니다.
다음 단계
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-30(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-30(UTC)"],[[["\u003cp\u003ePull queues in App Engine's standard environment require worker services to actively request tasks, unlike push queues where tasks are automatically delivered.\u003c/p\u003e\n"],["\u003cp\u003eWorkers using pull queues can utilize batching, which allows them to group related tasks by tags and retrieve them all at once for processing.\u003c/p\u003e\n"],["\u003cp\u003eWhen using pull queues, the worker must handle task scaling and task deletion, as opposed to push queues where these actions are handled by App Engine.\u003c/p\u003e\n"],["\u003cp\u003eThe process for working with a pull queue involves creating the queue, adding tasks to it, having a worker lease the task for a specified time, processing the task, and then deleting the task once completed.\u003c/p\u003e\n"],["\u003cp\u003ePull queues are created by modifying the \u003ccode\u003equeue.yaml\u003c/code\u003e file.\u003c/p\u003e\n"]]],[],null,["# Using Pull Queues in Python 2\n\nThis page provides an overview of pull queues in the App Engine\nstandard environment.\n| This API is supported for first-generation runtimes and can be used when [upgrading to corresponding second-generation runtimes](/appengine/docs/standard/\n| python3\n|\n| /services/access). If you are updating to the App Engine Python 3 runtime, refer to the [migration guide](/appengine/migration-center/standard/migrate-to-second-gen/python-differences) to learn about your migration options for legacy bundled services.\n\nIn *push* queues tasks are delivered to a worker service\nbased on the queue's configuration. In *pull* queues the worker service must *ask*\nthe queue for tasks. The queue responds by allowing that worker unique access\nto process the task for a specified period of time, which is called a *lease*.\n\nUsing pull queues, you can also group related tasks using tags and then configure your\nworker to pull multiple tasks with a certain tag all at once. This process is\ncalled *batching*.\n\nIf a worker cannot process a task before its lease expires, it can either renew the\nlease or let it expire, at which point another worker can acquire it. Once the\nwork associated with a task is complete, the worker must delete it.\n\nUsing pull queues requires your code to handle some functions that are automated\nin push queues:\n\nScaling your workers\n: Your code needs to scale the number of workers based on\n processing volume. If your code does not handle scaling, you risk\n wasting computing resources if there are no tasks to process; you also risk\n latency if you have too many tasks to process.\n\nDeleting the tasks\n: Your code also needs to explicitly delete tasks after processing.\n In push queues, App Engine deletes the tasks for you. If your worker does\n not delete pull queue tasks after processing, another worker will re-process\n the task. This wastes computing resources and risks errors if tasks are\n not [idempotent](https://wikipedia.org/wiki/Idempotence).\n\nPull queues in the App Engine standard environment are created by setting a property in a\nconfiguration file called `queue.yaml`.\n\nPull queue workflow\n-------------------\n\nWorkers that process tasks from pull queues must be defined within a service that runs\nin the App Engine standard environment.\n\nThe workflow is as follows:\n\n1. You [create a pull queue](/appengine/docs/legacy/standard/python/taskqueue/pull/creating-pull-queues), using `queue.yaml`.\n2. You [create tasks](/appengine/docs/legacy/standard/python/taskqueue/pull/creating-tasks) and add them to the queue.\n3. The worker you have created [leases the task](/appengine/docs/legacy/standard/python/taskqueue/pull/leasing-pull-tasks), using [TaskQueue.](/appengine/docs/legacy/standard/python/refdocs/google.appengine.api.taskqueue.taskqueue)\n4. App Engine sends task data to the worker in the lease response.\n5. The worker processes the task. If the task fails to execute before the lease expires, the worker can modify the lease duration. If the lease expires, the task will be available to be leased to another worker.\n6. After a task is processed successfully, the [worker deletes it](/appengine/docs/legacy/standard/python/taskqueue/pull/leasing-pull-tasks#deleting-tasks).\n\nWhat's next\n-----------\n\n- Learn how to [create pull queues](/appengine/docs/legacy/standard/python/taskqueue/pull/creating-pull-queues)."]]