Python 2.7 telah mencapai akhir dukungan
dan akan
dihentikan penggunaannya
pada 31 Januari 2026. Setelah penghentian penggunaan, Anda tidak akan dapat men-deploy aplikasi Python 2.7, meskipun organisasi Anda sebelumnya menggunakan kebijakan organisasi untuk mengaktifkan kembali deployment runtime lama. Aplikasi Python 2.7 yang ada akan terus berjalan dan menerima traffic setelah
tanggal penghentiannya. Sebaiknya Anda
bermigrasi ke versi Python terbaru yang didukung.
Menggunakan Pull Queue di Python 2
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Halaman ini menyediakan ringkasan pull queue di lingkungan standar App Engine.
Dalam push queue, tugas dikirim ke layanan worker berdasarkan konfigurasi antrean. Dalam pull queue, layanan worker harus meminta antrean tugas. Antrean merespons dengan mengizinkan akses unik pekerja tersebut untuk memproses tugas selama jangka waktu tertentu, yang disebut lease.

Dengan menggunakan pull queue, Anda juga dapat mengelompokkan tugas terkait menggunakan tag, lalu mengonfigurasi worker Anda untuk menarik beberapa tugas dengan tag tertentu sekaligus. Proses ini disebut batching.
Jika worker tidak dapat memproses tugas sebelum masa lease berakhir, worker dapat memperpanjang lease atau membiarkannya berakhir, sehingga worker lain dapat memperolehnya. Setelah tugas yang terkait dengan tugas selesai, worker harus menghapusnya.
Penggunaan pull queue mengharuskan kode Anda menangani beberapa fungsi yang diotomatiskan dalam push queue:
- Menskalakan worker Anda
- Kode Anda perlu menskalakan jumlah worker berdasarkan volume pemrosesan. Jika kode Anda tidak menangani penskalaan, Anda berisiko membuang resource komputasi jika tidak ada tugas yang harus diproses; Anda juga berisiko berlatensi jika terlalu banyak tugas untuk diproses.
- Menghapus tugas
- Kode Anda juga harus menghapus tugas secara eksplisit setelah diproses.
Dalam push queue, App Engine menghapus tugas untuk Anda. Jika worker Anda tidak menghapus tugas pull queue setelah pemrosesan selesai, worker lain akan memproses ulang tugas tersebut. Hal ini memboroskan resource komputasi dan menimbulkan error jika tugas tidak idempoten.
Pull queue di lingkungan standar App Engine dibuat dengan menetapkan properti dalam file konfigurasi bernama queue.yaml
.
Alur kerja pull queue
Worker yang memproses tugas dari pull queue harus ditentukan dalam layanan yang berjalan di lingkungan standar App Engine.
Alur kerjanya adalah sebagai berikut:
- Anda membuat pull queue menggunakan
queue.yaml
.
- Anda dapat membuat tugas dan menambahkannya ke antrean.
- Pekerja yang telah Anda buat menyewa tugas, menggunakan TaskQueue.
- App Engine mengirim data tugas ke worker dalam respons lease.
- Worker memproses tugas. Jika tugas gagal dieksekusi sebelum lease berakhir, worker dapat mengubah durasi lease. Jika lease berakhir, tugas akan tersedia untuk disewakan ke worker lain.
- Setelah tugas berhasil diproses, worker akan menghapusnya.
Langkah berikutnya
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-08-19 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-19 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)."]]