Créer des tâches de retrait
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Une fois que vous avez créé une file d'attente de retrait, vous pouvez créer des tâches et les ajouter à la file d'attente.
Pour commencer, vous avez besoin du nom de la file d'attente, défini dans le fichier queue.yaml
.
Ensuite, vous devez définir la tâche method
sur PULL
.
L'exemple suivant place les tâches dans une file d'attente appelée pull-queue
:
from google.appengine.api import taskqueue
q = taskqueue.Queue('pull-queue')
tasks = []
payload_str = 'hello world'
tasks.append(taskqueue.Task(payload=payload_str, method='PULL'))
q.add(tasks)
Étape suivante
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/04 (UTC)."],[[["\u003cp\u003ePull queues allow you to create and add tasks, as demonstrated in the provided example.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003equeue.yaml\u003c/code\u003e file contains the name of the queue, which is necessary for adding tasks.\u003c/p\u003e\n"],["\u003cp\u003eTasks in a pull queue are created by setting the \u003ccode\u003emethod\u003c/code\u003e to \u003ccode\u003ePULL\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe API is compatible with first-generation runtimes and can be used when upgrading to second-generation runtimes.\u003c/p\u003e\n"]]],[],null,["# Creating Pull Tasks\n\nOnce you have [created a pull\nqueue](/appengine/docs/legacy/standard/python/taskqueue/pull/creating-pull-queues), you\ncan create tasks and add them to the queue.\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\nFirst you need the [name](/appengine/docs/legacy/standard/python/config/queueref#name)\nof the queue, which is defined\nin `queue.yaml`.\nThen you set the\n[Task](/appengine/docs/legacy/standard/python/refdocs/google.appengine.api.taskqueue.taskqueue#google.appengine.api.taskqueue.taskqueue.Task)\n`method` to `PULL`.\n\n\nThe following example puts tasks in a pull queue named `pull-queue`: \n\n from google.appengine.api import taskqueue\n\n q = taskqueue.Queue('pull-queue')\n tasks = []\n payload_str = 'hello world'\n tasks.append(taskqueue.Task(payload=payload_str, method='PULL'))\n q.add(tasks)\n\nWhat's next\n-----------\n\n- Learn how to [lease tasks](/appengine/docs/legacy/standard/python/taskqueue/pull/leasing-pull-tasks)."]]