Raising a timed STOP
- Last Updated: March 30, 2020
- 3 minute read
- OpenEdge
- Version 12.2
- Documentation
The STOP-AFTER phrase on DO, FOR, or REPEAT statement establishes a timer on the block. If the timer expires
before execution of the block completes, the ABL session raises the STOP condition. At this point, normal STOP condition processing occurs and you can use the ON STOP phrase to handle the STOP.
The rules for executing synchronous remote procedure calls within a timed code block are essentially the same as those for local procedures. Remote procedures may be called within timed blocks or from blocks within timed blocks.
When a timed remote procedure call is executed on a PAS for OpenEdge instance, the
time limit for the procedure is enforced in the client session. If the timeout is
exceeded, the STOP condition is raised by the client.
In this context, a STOP message is sent to the server
session running the remote procedure after the specified time limit has exceeded, which
is similar to what happens when an interactive user presses the STOP key.
The following examples illustrate making timed synchronous remote procedure calls on a PAS for OpenEdge instance:
|
In this example, the client program (clntNested3.p) connects to a PAS for OpenEdge instance running on the local
host, and runs the local procedure foo within a timed
code block, specifying STOP-AFTER 5. The procedure
foo counts the number of customer records, and then
fills the character variable cParm with "X" characters. The remote procedure srvrNested3.p is then called. Because this remote procedure
call is made from within the timed procedure foo, srvrNested3.p is implicitly run as a timed procedure; the time limit for
this call is the time remaining for the timed block calling foo (5 seconds, less the time required to count the number of customer
records). The client session begins timing this when the remote procedure call is made.
If the call to srvrNested3.p does not return in the
client session within the 5 second time limit, the client session will issue a STOP message to the server session running
srvrNested3.p. When the PAS for OpenEdge instance receives the STOP message, the STOP
condition will be raised in the server session, as shown:
|
In srvrNested3.p running in the server
session, the INPUT-OUTPUT parameter p1 is filled with 30 "Y"
characters, and the spinHere procedure is called from
within a timed code block, with the time limit of 10 seconds (the value of srvrTimeLimit). In this example, spinHere is supposed to return after 15 seconds (the value of spinLimit). The procedure will ostensibly time out after 10
seconds, and the STOP condition will be raised.
However, the client session will issue the STOP message
to the server after 5 seconds, the STOP condition will
be raised in the client after 5 seconds (approximately).
Because srvrNested3.p employs default STOP handling (that is, the srvrNested3.p program does not specify an ON
STOP phrase), the STOP condition is not
handled by the server session. The timeout is consequently propagated back to the client
session.
It is important to note that the remote procedure call could also be made
within an explicit timed block. As with the local case, the actual time limit value used
by the RUN would be the smaller of the implicit and the
explicit time limit values.