|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > Internet and Network > MCP. - MCP (Model-Context Protocol) server operations > Task Management - Execute code and scripts > MCP Commands - Task Management |
MiniRobot Language (MRL) - MCP Task Management Commands
MCP.CheckJobResult / MCP.TaskCheckResult
Check Status and Result of Background Job
Purpose
The MCP.CheckJobResult command checks the current status of a background job and retrieves its result if completed. This is a non-blocking command that returns immediately with the job status, allowing you to poll for completion without freezing the robot.
This command is particularly useful when:
• Polling for job completion without blocking
• Implementing custom wait logic with other operations
• Checking multiple jobs in sequence
• Getting job status for logging or UI updates
Syntax
MCP.CheckJobResult|$$JOB_ID|$$STATUS_VAR|$$RESULT_VAR
MCP.TaskCheckResult|$$JOB_ID|$$STATUS_VAR|$$RESULT_VAR
Parameters
$$JOB_ID - The unique job ID returned by RunCodeAsync or RunScriptAsync.
$$STATUS_VAR - The variable that will receive the job status (running, completed, failed, not_found).
$$RESULT_VAR - The variable that will receive the job result or error message when completed.
Return Values
Status values:
running - Job is still executing
completed - Job finished successfully (result available)
failed - Job failed (error message in result)
not_found - Job ID does not exist or was cleaned up
Examples
' Example 1: Basic status check
MCP.RunCodeAsync|import time; time.sleep(5)|python|$$JobId
' ... do other work ...
MCP.CheckJobResult|$$JobId|$$Status|$$Result
PRT.Job status: $$Status
' Example 2: Polling loop with timeout
MCP.RunScriptAsync|C:\Scripts\long_task.py|$$TaskJob
VAR.$$Attempts|0
LBL.PollStart
MCP.CheckJobResult|$$TaskJob|$$Status|$$Result
IVV.$$Status!completed
ADD.$$Attempts|1
IVG.$$Attempts|10
PRT.Timeout waiting for job
JMP.PollEnd
EIF.
DLY.1000
JMP.PollStart
EIF.
PRT.Job completed: $$Result
LBL.PollEnd
' Example 3: Handle different statuses
MCP.CheckJobResult|$$JobId|$$Status|$$Result
SCS.$$Status
CAS.running
PRT.Job is still running...
CAS.completed
PRT.Job completed: $$Result
CAS.failed
PRT.Job failed: $$Result
CAS.not_found
PRT.Job not found (may have been cleaned up)
CSE.
Remarks
CheckJobResult and TaskCheckResult are aliases for the same command. You can use either form.
This is a non-blocking command - it returns immediately with the current status. For blocking waits, use MCP.WaitForJobResult instead.
Once a job reaches completed or failed status, the result remains available until the job is cleaned up using MCP.CleanupJobs.
Error Conditions
The command will fail with a parameter error if:
• The job ID parameter is missing
• The status variable parameter is missing
• The result variable parameter is missing
See also:
• MCP.WaitForJobResult - Wait for Job Completion
• MCP.GetJobResult - Get Job Result
• MCP.CleanupJobs - Clean Up Jobs
• MCP.RunCodeAsync - Execute Code Asynchronously