Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Fungsi library standarsys.sleep
menangguhkan eksekusi selama jumlah detik tertentu hingga maksimum 31536000 (satu tahun).
Menjeda alur kerja
Anda dapat menjeda eksekusi alur kerja dengan menambahkan langkah tidur ke definisi alur kerja. Langkah ini mencakup panggilan ke sys.sleep dan menentukan dalam
detik berapa lama Anda ingin menjeda alur kerja:
Anda juga dapat menggunakan sys.sleep untuk melakukan polling data selama interval tertentu. Misalnya,
Anda mungkin ingin melakukan polling API hingga kondisi tertentu terpenuhi:
[[["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-18 UTC."],[],[],null,["# Wait using polling\n\nThe `sys.sleep` [standard library function](/workflows/docs/reference/stdlib/sys/sleep)\nsuspends execution for the given number of seconds to a maximum of 31536000 (one\nyear).\n\nPause a workflow\n----------------\n\nYou can pause the execution of a workflow by adding a sleep step to your\nworkflow's definition. This step includes a call to `sys.sleep` and specifies in\nseconds how long you want to pause the workflow: \n\n### YAML\n\n```yaml\n - STEP_NAME:\n call: sys.sleep\n args:\n seconds: SLEEP_IN_SECONDS\n \n```\n\n### JSON\n\n```json\n [\n {\n \"\u003cvar translate=\"no\"\u003eSTEP_NAME\u003c/var\u003e\": {\n \"call\": \"sys.sleep\",\n \"args\": {\n \"seconds\": \"\u003cvar translate=\"no\"\u003eSLEEP_IN_SECONDS\u003c/var\u003e\"\n }\n }\n }\n ]\n \n```\n\nPoll for data\n-------------\n\nYou can also use `sys.sleep` to poll for data over a given interval. For example,\nyou might want to poll an API until a specific condition is met: \n\n### YAML\n\n```yaml\n main:\n params: [jobId]\n steps:\n - checkJob:\n call: http.get\n args:\n url: ${\"https://example.com/jobs/\" + jobId}\n auth:\n type: OAuth2\n result: jobStatus\n - checkIfDone:\n switch:\n - condition: ${jobStatus.complete}\n return: ${jobStatus}\n - wait:\n call: sys.sleep\n args:\n seconds: 60\n next: checkJob\n \n```\n\n### JSON\n\n```json\n {\n \"main\": {\n \"params\": [\n \"jobId\"\n ],\n \"steps\": [\n {\n \"checkJob\": {\n \"call\": \"http.get\",\n \"args\": {\n \"url\": \"${\\\"https://example.com/jobs/\\\" + jobId}\",\n \"auth\": {\n \"type\": \"OAuth2\"\n }\n },\n \"result\": \"jobStatus\"\n }\n },\n {\n \"checkIfDone\": {\n \"switch\": [\n {\n \"condition\": \"${jobStatus.complete}\",\n \"return\": \"${jobStatus}\"\n }\n ]\n }\n },\n {\n \"wait\": {\n \"call\": \"sys.sleep\",\n \"args\": {\n \"seconds\": 60\n },\n \"next\": \"checkJob\"\n }\n }\n ]\n }\n }\n \n```"]]