LocalSubmit

LocalSubmit[expr]

submits a task to evaluate expr in a separate kernel.

LocalSubmit[ScheduledTask[expr, spec]]

submits a task to evaluate expr in a separate kernel on the schedule defined by spec.

Details and Options

  • LocalSubmit[] returns TaskObject[] to represent the task it creates.
  • Possible values of spec are those supported by the ScheduledTask.
  • The following options can be given:
  • HandlerFunctions<||>how to handle generated events
    HandlerFunctionsKeysAutomaticparameters to supply to handler functions
  • During the execution of the task, the following events can be generated:
  • "TaskStarted"task is started
    "FailureOccurred"task could not be started
    "ScheduleTriggered"scheduled task evaluation is beginning
    "MessageGenerated"evaluation generated a message
    "PrintOutputGenerated"evaluation generated print output
    "ResultReceived"evaluation generated a result
    "ScheduleExecuted"scheduled task evaluation is executed
    "TaskStatusChanged"task status changed
    "TaskFinished"task is completely finished
    "TaskRemoved"task is being removed
  • With the specification HandlerFunctions-><|,"eventi"->fi,|>, fi[assoc] is evaluated whenever eventi is generated. The elements of assoc have keys specified by the setting for HandlerFunctionsKeys.
  • Possible keys specified by HandlerFunctionsKeys include:
  • "EvaluationExpression"expression being evaluated
    "EvaluationResult"result of the evaluation
    "Failure"failure object generated if task failed
    "MessageOutput"content of message generated
    "PrintOutput"content of print output generated
    "Task"the object representing the task
    "TaskStatus"the status of the task
    "TaskType"type of the task
    "TaskUUID"unique task identifier
    "EventName"the name of the event being handled
  • The expression to evaluate is returned wrapped in Hold.
  • For scheduled tasks, the following additional keys can be specified:
  • "Schedule"task schedule specification
    "RunInterval"interval between task runs
    "PreviousRunCount"number of times the task has already run
    "RemainingRunCount"number of times the task still has to run
    "TotalRunCount"total number of times the task is scheduled to run
    "NextScheduledTime"next time the task is scheduled to run
  • LocalSubmit initiates a new subkernel whenever it is called.

Examples

open allclose all

Basic Examples  (8)

Start a separate kernel to evaluate the expression and get notified when it is finished:

Assign the result of the evaluation to a variable in your current session:

processID gets a value:

Evaluate an expression in a separate kernel and get the result when it is ready:

Capture messages generated by the remote kernel:

Format message output as a regular message:

Capture print output generated by the remote kernel:

Format message output as a regular message:

Get notified when the task status changes:

If the subkernel terminates before the evaluation is complete, a Failure object is generated:

Start a remote kernel and evaluate an expression, which may take a long time to finish:

Check which tasks are currently running:

Terminate the tasks without waiting for them to finish:

Possible Issues  (1)

Print evaluated on a remote kernel is not printed locally:

Set up handlers to capture a "PrintOutputGenerated" event and print locally:

Wolfram Research (2017), LocalSubmit, Wolfram Language function, https://reference.wolfram.com/language/ref/LocalSubmit.html (updated 2019).

Text

Wolfram Research (2017), LocalSubmit, Wolfram Language function, https://reference.wolfram.com/language/ref/LocalSubmit.html (updated 2019).

CMS

Wolfram Language. 2017. "LocalSubmit." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2019. https://reference.wolfram.com/language/ref/LocalSubmit.html.

APA

Wolfram Language. (2017). LocalSubmit. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/LocalSubmit.html

BibTeX

@misc{reference.wolfram_2024_localsubmit, author="Wolfram Research", title="{LocalSubmit}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/LocalSubmit.html}", note=[Accessed: 22-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_localsubmit, organization={Wolfram Research}, title={LocalSubmit}, year={2019}, url={https://reference.wolfram.com/language/ref/LocalSubmit.html}, note=[Accessed: 22-November-2024 ]}