Panel | ||||
---|---|---|---|---|
|
Introduction
The Dynamic Command created in the previous chapter always runs in a separate process from the Extension instance. In this chapter, In-process Dynamic Commands will be introduced, which run within the process of an associated Extension instance. As a result of running "in-process", the dynamic commands can impact the execution of the Extension instance.
...
Info |
---|
The steps below assume Controller version is at least 7.1.0.0 |
Step 1 - Add Asynchronous In-Process Dynamic Command to the "UE Task" Universal Template
Go back to the "UE Task" Universal Template form.
...
Also note that the "Execution Option" is explicitly set to In Process, and the Asynchronous option is checked.
Step 2 - Add Synchronous In-Process Dynamic Command to the "UE Task" Universal Template
Go back to the "UE Task" Universal Template form.
...
Also note that the "Execution Option" is explicitly set to In Process, and the Asynchronous option is NOT checked.
Step 3 - Add a new text field to the "UE Task" Universal Template
Go back to the "UE Task" Universal Template form.
...
Ensure that the default value is set to ABCD
Step 4 - Add a backing implementation for both Asynchronous and Synchronous In-Process Dynamic Commands to the extension.py file
Open file ~/dev/extensions/sample-task/src/extension.py
in your editor of choice.
...
Line 75-98 | The complete implementation of async_print_word() is defined. In short, the method adds each letter of self.WORD to self.async_queue. If self.async_index is odd, the function sleeps for 5 seconds before adding it to self.async_queue. |
Line 100-123 | The complete implementation of sync_print_word() is defined. The method does the exact same thing as async_print_word() except it works with self.sync_queue and self.sync_index. |
Lines 143-156 | The extension_start() method grabs the value of the word field and initializes the queues and index variables. It sleeps for 40 seconds to keep the process running as required by the In-Process Dynamic commands. At the end, it prints out the queues. |
Step 5 - Build and Upload the Extension Zip Archive Using the UIP VS Code Extension
Save all changes to extension.py.
...
Expand | ||
---|---|---|
| ||
Step 5 Supplemental - Build and Upload the Extension Zip Archive Using the CLISave all changes to extension.py. From the command line, cd to the ~/dev/extensions/sample-task directory and execute the push command as shown below: Recall that the push command builds and uploads the Extension zip archive |
Step 6 - Execute the Asynchronous Dynamic Command
In the Controller, open a "UE Task Tasks" tab. If the tab is already open, it must be closed and reopened before the new In-Process Dynamic Commands are available on the task instances.
...
The exception occurred first, but that did not prevent the log statements from being printed in extension_start()
Step 7 - Execute the Synchronous Dynamic Command
In the Controller, open a "UE Task Tasks" tab. If the tab is already open, it must be closed and reopened before the new In-Process Dynamic Commands are available on the task instances.
...
Similar to the Asynchronous Dynamic Command, the Exception does not impact the Extension instance or any other Dynamic Command instances.
Step 8 - Update the Local template.json
In steps 1 to 3, we modified the Universal Template by adding new Dynamic Commands.
...
Right now, they are not both the same. The Controller's version of template.json has the In-Process Dynamic Command changes. To grab those changes, use the pull command as shown below:
UIP VS Code Extension
Expand | ||
---|---|---|
| ||
Step Supplemental - CLI |
Now, both the local and Controller's version of the Universal Template are the same.