How Can I use Job Command in Embedded Python?
How Job command can be used with Embedded Python code?
Comments
Do you want to job ObjectScript code? Write a wrapper class method and call it from embedded python.
Thanks Ed!
It is more that I convert ObjectScript to Python and it get stuck on Job command. Thought of something universal for such cases.
Hi Evgeny,
The following is a tool System Management Specialists may use.
You can achieve Jobbing and also running arbitrary ObjectScript code by employing RunLegacyTask.
For example run arbitrary code:
USER>zw ^ABC
USER>D $SYSTEM.Python.Shell()
Python 3.9.5 (default, Mar 14 2023, 06:58:44) [MSC v.1927 64 bit (AMD64)] on win32
Type quit() or Ctrl-D to exit this shell.
>>> myjob=iris.cls("%SYS.Task.RunLegacyTask")._New()
>>> myjob.ExecuteCode="Set ^ABC=""123"""
>>> res=myjob.OnTask()
>>> res
1
>>> quit()
USER>zw ^ABC
^ABC=123For example Jobbing a Routine.
Routine (Test.mac) source code:
TestSet ^ABC=345Quit
Use legacy Task to Job it off:
USER>zw ^ABC
^ABC=123
USER>D $SYSTEM.Python.Shell()
Python 3.9.5 (default, Mar 14 2023, 06:58:44) [MSC v.1927 64 bit (AMD64)] on win32
Type quit() or Ctrl-D to exit this shell.
>>> myjob=iris.cls("%SYS.Task.RunLegacyTask")._New()
>>> myjob.ExecuteCode="Job Test^Test"
>>> res=myjob.OnTask()
>>> res
1
>>> quit()
USER>zw ^ABC
^ABC=345The status result can be useful to understand problems.
For example the Routine line label "Test" was miss-typed as "TEST"
>>> myjob=iris.cls("%SYS.Task.RunLegacyTask")._New()
>>> myjob.ExecuteCode="Job TEST^Test"
>>> res=myjob.OnTask()
>>> iris.cls("%SYSTEM.Status").DisplayError(res)
ERROR #5001: <NOLINE>zexecuteCode+3^%SYS.Task.RunLegacyTask.11Enjoy IRIS. No limits :)
Haha, this is good, @Alex Woodhead ! Thank you!
Take a look at the WorkQueue Manager which also allows for coordination.
workQueue =iris.cls("%SYSTEM.WorkMgr")._New()
status = workQueue.Queue("..PythonClassMethodToBeJobbed")
[Note routines require function [parentheses] not just a plain label - so for Alex's example below will need Test()]
Thank you @James MacKeith ! This is interesting, never touched our WorkQueue Manager before.