sys.sleep הפונקציה בספרייה הרגילה
משעה את הביצוע למספר השניות שצוין, עד למקסימום של 31,536,000 (שנה אחת).
השהיית תהליך עבודה
אתם יכולים להשהות את ההפעלה של תהליך עבודה על ידי הוספת שלב שינה להגדרה של תהליך העבודה. השלב הזה כולל קריאה ל-sys.sleep ומציין בשניות את משך ההשהיה הרצוי של תהליך העבודה:
YAML
- STEP_NAME: call: sys.sleep args: seconds: SLEEP_IN_SECONDS
JSON
[ { "STEP_NAME": { "call": "sys.sleep", "args": { "seconds": "SLEEP_IN_SECONDS" } } } ]
איך שולחים בקשה לנתונים
אפשר גם להשתמש ב-sys.sleep כדי לשלוח בקשות לנתונים במרווחים קבועים. לדוגמה, יכול להיות שתרצו לבצע דגימה של API עד שתנאי מסוים יתקיים:
YAML
main: params: [jobId] steps: - checkJob: call: http.get args: url: ${"https://example.com/jobs/" + jobId} auth: type: OAuth2 result: jobStatus - checkIfDone: switch: - condition: ${jobStatus.complete} return: ${jobStatus} - wait: call: sys.sleep args: seconds: 60 next: checkJob
JSON
{ "main": { "params": [ "jobId" ], "steps": [ { "checkJob": { "call": "http.get", "args": { "url": "${\"https://example.com/jobs/\" + jobId}", "auth": { "type": "OAuth2" } }, "result": "jobStatus" } }, { "checkIfDone": { "switch": [ { "condition": "${jobStatus.complete}", "return": "${jobStatus}" } ] } }, { "wait": { "call": "sys.sleep", "args": { "seconds": 60 }, "next": "checkJob" } } ] } }