[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-18。"],[],[],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```"]]