Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0846ff1

Browse files
cohultgitbook-bot
authored andcommitted
GITBOOK-317: cohult/ENG-36506 action abort callback example
1 parent 3faf4cc commit 0846ff1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

development/introduction-to-automation/applications-in-nso.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,10 @@ result 3
386386

387387
You can use the `show devices list` command to verify that the result is correct. You can alter the address of any device and see how it affects the result. You can even use a hostname, such as `localhost`.
388388

389+
{% hint style="info" %}
390+
Other examples of action implementations can be found under [examples.ncs/sdk-api](https://github.com/NSO-developer/nso-examples/tree/main/sdk-api).
391+
{% endhint %}
392+
389393
## Overview of Extension Points
390394

391395
NSO supports a number of extension points for custom callbacks:
@@ -457,6 +461,10 @@ There are some important points worth noting for action timeout:
457461
* An action callback that times out in one user instance will not affect the result of an action callback in another user instance. This is because NSO executes actions using multiple worker sockets, and an action timeout will only terminate the worker socket executing that specific action.
458462
* Implementing your own abort action callback in `cb_abort` allows you to handle actions that are timing out. If `cb_abort` is not defined, NSO cannot trigger the abort action during a timeout, preventing it from unlocking the action for a user session. Consequently, you must wait for the action callback to finish before attempting it again.
459463

464+
{% hint style="info" %}
465+
See [examples.ncs/sdk-api/action-abort-py](https://github.com/NSO-developer/nso-examples/tree/main/sdk-api/action-abort-py) for an example of how to implement an abortable Python action that spawns a separate worker process using the multiprocessing library and returns the worker's outcome via a result queue or terminates the worker if the action is aborted. 
466+
{% endhint %}
467+
460468
For NSO operational data queries, NSO uses `query-timeout` to ensure the data provider return operational data within the given time. If the data provider fails to do so within the stipulated timeout, NSO will close its end of the control socket to the data provider. The NSO VMs will detect the socket close and exit.
461469

462470
For connection initiation requests between NSO and data providers, NSO uses `connect-timeout` to ensure the data provider send the initial message after connecting the socket to NSO within the given time. If the data provider fails to do so within the stipulated timeout, NSO will close its end of the control socket to the data provider. The NSO VMs will detect the socket close and exit.

0 commit comments

Comments
 (0)