Advanced Octave A59 — Job progress and cancellation

by Giux GX-TXT, octave-en, scripts-en 2 min read

Advanced GNU Octave with GX-TXT · Module 10

In a block processing it is useful to communicate the phase and how many blocks have been completed. Early arrest also requires to declare whether the result is partial.

Objectives and prerequisites

We use the Runner and the Script Bridge introduced in the first module. The test uses GX-TXT dev112-P011-bis and GNU Octave 9.4.0. Import avanzamento.m, register it and run it in the Runner.

Events and Controlled Stop

PROGRESS_API_v1/publish receives structured events with status, mode, phase, message, current and total value. The script publishes start, running updates and finally completed. The current and total fields describe progress; reaching the total does not replace the explicit declaration of the final state.

To make a partial result visible, the stop_after variable is fixed at 7: the cycle goes out after the seventh block of ten and prints the reason. The execution ends normally and the final event declares a partial example completed; it does not claim that all ten blocks have been processed.

Effective cancellation

The stop of the example is decided by the program: it is not a proof of the Job cancellation button. A user request to a Job and a cooperative interruption are different mechanisms; the effects depend on the runner and contract of the operation. Do not assume that a request immediately terminates work or automatically produces usable results. An application must explicitly manage resources, status and partial results according to the available APIs.

Exercise

  1. How many blocks are processed in the test?
  2. Why doesn’t completed mean that all ten blocks have been processed?
  3. Does the script prove that a Job can be deleted instantly from the GUI?

Worked solution

  1. Seven.
  2. The execution normally ends after an arrest provided by the program and declares that the result is partial.
  3. No: a deletion from the GUI has not been performed or verified.

Download the Module 10 scripts (ZIP)

#GNU Octave #GX-TXT #GX-TXT public APIs

Other steps of this project

Leave a Reply

Your email address will not be published. Required fields are marked *