iris-pex-embedded-python 3.5.5b4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- grongier/__init__.py +0 -0
- grongier/cls/Grongier/PEX/BusinessOperation.cls +8 -0
- grongier/cls/Grongier/PEX/BusinessProcess.cls +13 -0
- grongier/cls/Grongier/PEX/BusinessService.cls +8 -0
- grongier/cls/Grongier/PEX/Common.cls +10 -0
- grongier/cls/Grongier/PEX/Director.cls +10 -0
- grongier/cls/Grongier/PEX/Duplex/Operation.cls +4 -0
- grongier/cls/Grongier/PEX/Duplex/Process.cls +13 -0
- grongier/cls/Grongier/PEX/Duplex/Service.cls +4 -0
- grongier/cls/Grongier/PEX/InboundAdapter.cls +8 -0
- grongier/cls/Grongier/PEX/Message.cls +13 -0
- grongier/cls/Grongier/PEX/OutboundAdapter.cls +8 -0
- grongier/cls/Grongier/PEX/PickleMessage.cls +13 -0
- grongier/cls/Grongier/PEX/PrivateSession/Duplex.cls +8 -0
- grongier/cls/Grongier/PEX/PrivateSession/Message/Ack.cls +14 -0
- grongier/cls/Grongier/PEX/PrivateSession/Message/Poll.cls +14 -0
- grongier/cls/Grongier/PEX/PrivateSession/Message/Start.cls +14 -0
- grongier/cls/Grongier/PEX/PrivateSession/Message/Stop.cls +14 -0
- grongier/cls/Grongier/PEX/Test.cls +10 -0
- grongier/cls/Grongier/PEX/Utils.cls +10 -0
- grongier/cls/Grongier/Service/WSGI.cls +4 -0
- grongier/pex/__init__.py +24 -0
- grongier/pex/__main__.py +4 -0
- grongier/pex/_business_host.py +1 -0
- grongier/pex/_cli.py +4 -0
- grongier/pex/_common.py +1 -0
- grongier/pex/_director.py +1 -0
- grongier/pex/_utils.py +1 -0
- grongier/pex/wsgi/handlers.py +104 -0
- iop/__init__.py +25 -0
- iop/__main__.py +4 -0
- iop/_async_request.py +67 -0
- iop/_business_host.py +256 -0
- iop/_business_operation.py +75 -0
- iop/_business_process.py +224 -0
- iop/_business_service.py +63 -0
- iop/_cli.py +247 -0
- iop/_common.py +334 -0
- iop/_debugpy.py +187 -0
- iop/_decorators.py +49 -0
- iop/_director.py +301 -0
- iop/_dispatch.py +136 -0
- iop/_generator_request.py +30 -0
- iop/_inbound_adapter.py +34 -0
- iop/_iris.py +8 -0
- iop/_log_manager.py +100 -0
- iop/_message.py +40 -0
- iop/_message_validator.py +49 -0
- iop/_outbound_adapter.py +23 -0
- iop/_private_session_duplex.py +103 -0
- iop/_private_session_process.py +41 -0
- iop/_remote.py +91 -0
- iop/_serialization.py +199 -0
- iop/_utils.py +671 -0
- iop/cls/IOP/BusinessOperation.cls +35 -0
- iop/cls/IOP/BusinessProcess.cls +156 -0
- iop/cls/IOP/BusinessService.cls +40 -0
- iop/cls/IOP/Common.cls +569 -0
- iop/cls/IOP/Director.cls +70 -0
- iop/cls/IOP/Duplex/Operation.cls +29 -0
- iop/cls/IOP/Duplex/Process.cls +229 -0
- iop/cls/IOP/Duplex/Service.cls +9 -0
- iop/cls/IOP/Generator/Message/Ack.cls +31 -0
- iop/cls/IOP/Generator/Message/Poll.cls +31 -0
- iop/cls/IOP/Generator/Message/Start.cls +15 -0
- iop/cls/IOP/Generator/Message/StartPickle.cls +15 -0
- iop/cls/IOP/Generator/Message/Stop.cls +32 -0
- iop/cls/IOP/InboundAdapter.cls +22 -0
- iop/cls/IOP/Message/JSONSchema.cls +125 -0
- iop/cls/IOP/Message.cls +754 -0
- iop/cls/IOP/OutboundAdapter.cls +36 -0
- iop/cls/IOP/PickleMessage.cls +58 -0
- iop/cls/IOP/PrivateSession/Duplex.cls +260 -0
- iop/cls/IOP/PrivateSession/Message/Ack.cls +32 -0
- iop/cls/IOP/PrivateSession/Message/Poll.cls +32 -0
- iop/cls/IOP/PrivateSession/Message/Start.cls +31 -0
- iop/cls/IOP/PrivateSession/Message/Stop.cls +48 -0
- iop/cls/IOP/Projection.cls +49 -0
- iop/cls/IOP/Service/Remote/Handler.cls +30 -0
- iop/cls/IOP/Service/Remote/Rest/v1.cls +97 -0
- iop/cls/IOP/Service/WSGI.cls +310 -0
- iop/cls/IOP/Test.cls +85 -0
- iop/cls/IOP/Utils.cls +503 -0
- iop/cls/IOP/Wrapper.cls +58 -0
- iop/wsgi/handlers.py +104 -0
- iris_pex_embedded_python-3.5.5b4.dist-info/METADATA +91 -0
- iris_pex_embedded_python-3.5.5b4.dist-info/RECORD +91 -0
- iris_pex_embedded_python-3.5.5b4.dist-info/WHEEL +5 -0
- iris_pex_embedded_python-3.5.5b4.dist-info/entry_points.txt +2 -0
- iris_pex_embedded_python-3.5.5b4.dist-info/licenses/LICENSE +21 -0
- iris_pex_embedded_python-3.5.5b4.dist-info/top_level.txt +2 -0
iop/cls/IOP/Common.cls
ADDED
|
@@ -0,0 +1,569 @@
|
|
|
1
|
+
/* Copyright (c) 2021 by InterSystems Corporation.
|
|
2
|
+
Cambridge, Massachusetts, U.S.A. All rights reserved.
|
|
3
|
+
Confidential property of InterSystems Corporation. */
|
|
4
|
+
|
|
5
|
+
Include Ensemble
|
|
6
|
+
|
|
7
|
+
Class IOP.Common [ Abstract, ClassType = "", ProcedureBlock, System = 4 ]
|
|
8
|
+
{
|
|
9
|
+
|
|
10
|
+
/// One or more Classpaths (separated by '|' character)
|
|
11
|
+
Property %classpaths As %String(MAXLEN = "");
|
|
12
|
+
|
|
13
|
+
/// Classname of the Python class to use
|
|
14
|
+
Property %classname As %String(MAXLEN = "");
|
|
15
|
+
|
|
16
|
+
/// Module of the Python class to use
|
|
17
|
+
Property %module As %String(MAXLEN = "");
|
|
18
|
+
|
|
19
|
+
/// Settings for the Python class, in the form of "property=value" pairs, separated by newlines
|
|
20
|
+
/// Example: "property1=value1\nproperty2=value2"
|
|
21
|
+
/// Note: This property is used to set the properties of the Python class dynamically
|
|
22
|
+
Property %settings As %String(MAXLEN = "");
|
|
23
|
+
|
|
24
|
+
/// Instance of class
|
|
25
|
+
Property %class As %SYS.Python;
|
|
26
|
+
|
|
27
|
+
/// Enable debugging
|
|
28
|
+
/// If set to 1, the Python class will be debugged using the debugpy module
|
|
29
|
+
/// If set to 0, the Python class will not be debugged
|
|
30
|
+
Property %enable As %Boolean;
|
|
31
|
+
|
|
32
|
+
/// Timeout in seconds for the an client debugging connection
|
|
33
|
+
Property %timeout As %Numeric [ InitialExpression = 30 ];
|
|
34
|
+
|
|
35
|
+
/// Port to use for the an client debugging connection
|
|
36
|
+
Property %port As %Numeric [ InitialExpression = 0 ];
|
|
37
|
+
|
|
38
|
+
/// Path to the Python interpreter for debugpy
|
|
39
|
+
Property %PythonInterpreterPath As %String(MAXLEN = 255);
|
|
40
|
+
|
|
41
|
+
/// Enable traceback display
|
|
42
|
+
Property %traceback As %Boolean [ InitialExpression = 1 ];
|
|
43
|
+
|
|
44
|
+
/// Enable virtual environment
|
|
45
|
+
Property %Venv As %Boolean [ InitialExpression = 0 ];
|
|
46
|
+
|
|
47
|
+
/// Virtual environment site-packages path
|
|
48
|
+
Property %PythonPath As %String(MAXLEN = 255);
|
|
49
|
+
|
|
50
|
+
/// Path to the Python runtime library
|
|
51
|
+
Property %PythonRuntimeLibrary As %String(MAXLEN = 255);
|
|
52
|
+
|
|
53
|
+
/// Version of the Python runtime library
|
|
54
|
+
Property %PythonRuntimeLibraryVersion As %String;
|
|
55
|
+
|
|
56
|
+
/// Get Class
|
|
57
|
+
Method GetClass() As %SYS.Python
|
|
58
|
+
{
|
|
59
|
+
Return ..%class
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/// Get Classname
|
|
63
|
+
Method GetClassname() As %String
|
|
64
|
+
{
|
|
65
|
+
Return ..%classname
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/// Get Classname
|
|
69
|
+
Method GetModule() As %String
|
|
70
|
+
{
|
|
71
|
+
Return ..%module
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
Method DisplayTraceback(ex) As %Status
|
|
75
|
+
{
|
|
76
|
+
set tSC = ex.AsStatus()
|
|
77
|
+
// Check if traceback is enabled
|
|
78
|
+
if ..%traceback {
|
|
79
|
+
// Import Modules
|
|
80
|
+
set sys = ##class(%SYS.Python).Import("sys")
|
|
81
|
+
set tracebackModule = ##class(%SYS.Python).Import("traceback")
|
|
82
|
+
set builtins = ##class(%SYS.Python).Import("builtins")
|
|
83
|
+
// Get the last traceback
|
|
84
|
+
set traceback = sys."last_traceback"
|
|
85
|
+
set exType = sys."last_type"."__name__"
|
|
86
|
+
set exValue = sys."last_value"."__str__"()
|
|
87
|
+
// Check if traceback is an object
|
|
88
|
+
if $isObject(traceback) {
|
|
89
|
+
// Format the traceback
|
|
90
|
+
set tb = tracebackModule."format_exception"(sys."last_type", sys."last_value", traceback)
|
|
91
|
+
set tbString = ""
|
|
92
|
+
for i=0:1:(tb."__len__"()-1) {
|
|
93
|
+
set tbString = tbString _ $c(10)_$c(13) _ tb."__getitem__"(i)
|
|
94
|
+
}
|
|
95
|
+
$$$LOGERROR(tbString)
|
|
96
|
+
set tSC = $$$ERROR($$$EnsErrGeneral,"Exception in Python class: "_..%classname_" - "_exType_" - "_exValue)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return tSC
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
Method OnInit() As %Status
|
|
103
|
+
{
|
|
104
|
+
set tSC = $$$OK
|
|
105
|
+
|
|
106
|
+
try {
|
|
107
|
+
|
|
108
|
+
if ..%Venv {
|
|
109
|
+
$$$ThrowOnError(##class(IOP.Utils).SetPythonSettings(..%PythonRuntimeLibrary, ..%PythonPath, ..%PythonRuntimeLibraryVersion))
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
do ..DisplayPythonVersion()
|
|
113
|
+
|
|
114
|
+
do $system.Python.Debugging(..%traceback)
|
|
115
|
+
|
|
116
|
+
$$$ThrowOnError(..Connect())
|
|
117
|
+
|
|
118
|
+
do ..%class."_debugpy"($this)
|
|
119
|
+
|
|
120
|
+
do ..%class."_dispatch_on_init"($this)
|
|
121
|
+
} catch ex {
|
|
122
|
+
|
|
123
|
+
set tSC = ..DisplayTraceback(ex)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
quit tSC
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
Method DisplayPythonVersion()
|
|
130
|
+
{
|
|
131
|
+
set sys = ##class(%SYS.Python).Import("sys")
|
|
132
|
+
set version = sys.version
|
|
133
|
+
set versionInfo = sys."version_info"
|
|
134
|
+
set major = versionInfo.major
|
|
135
|
+
set minor = versionInfo.minor
|
|
136
|
+
set micro = versionInfo.micro
|
|
137
|
+
set releaseLevel = versionInfo.releaselevel
|
|
138
|
+
set serial = versionInfo.serial
|
|
139
|
+
|
|
140
|
+
$$$LOGINFO("Python Version: "_ version)
|
|
141
|
+
$$$LOGINFO("Version Info: "_ major_ "."_ minor_ "."_ micro_" ("_ releaseLevel_ ", "_serial_ ")")
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
ClassMethod SetPythonPath(pClasspaths)
|
|
145
|
+
{
|
|
146
|
+
set sys = ##class(%SYS.Python).Import("sys")
|
|
147
|
+
|
|
148
|
+
// Add the classpaths to the Python sys.path only if they are not already present
|
|
149
|
+
// Check if the path is already in sys.path
|
|
150
|
+
set found = 0
|
|
151
|
+
for j=1:1:sys.path."__len__"() {
|
|
152
|
+
if sys.path."__getitem__"(j-1) = pClasspaths {
|
|
153
|
+
set found = 1
|
|
154
|
+
quit
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if found = 0 {
|
|
158
|
+
// If not found, add to sys.path
|
|
159
|
+
do sys.path."append"(pClasspaths)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
Method Connect() As %Status
|
|
164
|
+
{
|
|
165
|
+
set tSC = $$$OK
|
|
166
|
+
try {
|
|
167
|
+
// Initialize Python class instance
|
|
168
|
+
$$$ThrowOnError(..InitializePythonClass())
|
|
169
|
+
|
|
170
|
+
// Set IRIS handles based on component type
|
|
171
|
+
do ..SetIrisHandles()
|
|
172
|
+
|
|
173
|
+
// Apply property values to Python instance
|
|
174
|
+
do ..SetPropertyValues()
|
|
175
|
+
|
|
176
|
+
// Notify Python class of connection
|
|
177
|
+
try {
|
|
178
|
+
do ..%class."_dispatch_on_connected"($this)
|
|
179
|
+
} catch ex {
|
|
180
|
+
$$$LOGWARNING(ex.DisplayString())
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
} catch ex {
|
|
184
|
+
set msg = $System.Status.GetOneStatusText(ex.AsStatus(),1)
|
|
185
|
+
set tSC = $$$ERROR($$$EnsErrGeneral,msg)
|
|
186
|
+
}
|
|
187
|
+
quit tSC
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
Method OnTearDown() As %Status
|
|
191
|
+
{
|
|
192
|
+
set tSC = $$$OK
|
|
193
|
+
if $isObject(..%class) {
|
|
194
|
+
try {
|
|
195
|
+
do ..%class."_dispatch_on_tear_down"()
|
|
196
|
+
} catch ex {
|
|
197
|
+
set tSC = ex.AsStatus()
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
quit tSC
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
Method SetPropertyValues()
|
|
204
|
+
{
|
|
205
|
+
// First process the %settings property
|
|
206
|
+
set remoteSettings = $tr(..%settings,$c(13))
|
|
207
|
+
for i=1:1:$l(remoteSettings,$c(10)) {
|
|
208
|
+
set oneLine = $p(remoteSettings,$c(10),i)
|
|
209
|
+
set property = $p(oneLine,"=",1) continue:property=""
|
|
210
|
+
set value = $p(oneLine,"=",2,*)
|
|
211
|
+
try {
|
|
212
|
+
set $property(..%class,property) = value
|
|
213
|
+
} catch ex {
|
|
214
|
+
$$$LOGWARNING(ex.DisplayString())
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Now process the Python Attributes Settings
|
|
219
|
+
// First list all the properties of the current class
|
|
220
|
+
set class = $CLASSNAME()
|
|
221
|
+
set tSQL = "SELECT * FROM %Dictionary.PropertyDefinition WHERE parent = ?"
|
|
222
|
+
set tSQL = tSQL _ " AND name <> '%timeout'"
|
|
223
|
+
set tSQL = tSQL _ " and name <> '%enable'"
|
|
224
|
+
set tSQL = tSQL _ " and name <> '%classpaths'"
|
|
225
|
+
set tSQL = tSQL _ " and name <> '%classname'"
|
|
226
|
+
set tSQL = tSQL _ " and name <> '%module'"
|
|
227
|
+
set tSQL = tSQL _ " and name <> '%port'"
|
|
228
|
+
set tSQL = tSQL _ " and name <> '%PythonInterpreterPath'"
|
|
229
|
+
set tSQL = tSQL _ " and name <> '%traceback'"
|
|
230
|
+
set tSQL = tSQL _ " and name <> '%PythonPath'"
|
|
231
|
+
set tSQL = tSQL _ " and name <> '%PythonRuntimeLibrary'"
|
|
232
|
+
set tSQL = tSQL _ " and name <> '%PythonRuntimeLibraryVersion'"
|
|
233
|
+
set tSQL = tSQL _ " and name <> '%settings'"
|
|
234
|
+
set tSQL = tSQL _ " and name <> '%Venv'"
|
|
235
|
+
|
|
236
|
+
set tStmt = ##class(%SQL.Statement).%New()
|
|
237
|
+
|
|
238
|
+
set tSC = tStmt.%Prepare(tSQL)
|
|
239
|
+
if $$$ISERR(tSC) {
|
|
240
|
+
$$$LOGERROR("Error preparing SQL statement: "_tSC)
|
|
241
|
+
quit
|
|
242
|
+
}
|
|
243
|
+
set tRs = tStmt.%Execute(class)
|
|
244
|
+
|
|
245
|
+
while tRs.%Next() {
|
|
246
|
+
set property = tRs.%Get("Name")
|
|
247
|
+
set value = $property($this,property)
|
|
248
|
+
|
|
249
|
+
if value'="" {
|
|
250
|
+
try {
|
|
251
|
+
set $property(..%class,property) = value
|
|
252
|
+
} catch ex {
|
|
253
|
+
$$$LOGWARNING(ex.DisplayString())
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
quit
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
Method dispatchSendRequestSync(
|
|
262
|
+
pTarget,
|
|
263
|
+
pRequest,
|
|
264
|
+
timeout,
|
|
265
|
+
pDescription) As %String
|
|
266
|
+
{
|
|
267
|
+
set tSC = ..SendRequestSync(pTarget,pRequest,.objResponse,timeout,pDescription)
|
|
268
|
+
if $$$ISERR(tSC) throw ##class(%Exception.StatusException).CreateFromStatus(tSC)
|
|
269
|
+
quit $g(objResponse)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
Method dispatchSendRequestSyncMultiple(
|
|
273
|
+
pCallStructList As %List,
|
|
274
|
+
pTimeout As %Numeric = -1) As %List
|
|
275
|
+
{
|
|
276
|
+
set builtins = ##class(%SYS.Python).Import("builtins")
|
|
277
|
+
// Convert %List to multidimensional array
|
|
278
|
+
set tCallStructList=builtins.len(pCallStructList)
|
|
279
|
+
for i=0:1:builtins.len(pCallStructList)-1 {
|
|
280
|
+
set tCallStructList(i+1) = pCallStructList."__getitem__"(i)
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
set tSC = ..SendRequestSyncMultiple(.tCallStructList,pTimeout)
|
|
284
|
+
if $$$ISERR(tSC) throw ##class(%Exception.StatusException).CreateFromStatus(tSC)
|
|
285
|
+
|
|
286
|
+
// Convert multidimensional array to Python list
|
|
287
|
+
set tResponseList = builtins.list()
|
|
288
|
+
|
|
289
|
+
for i=1:1:tCallStructList {
|
|
290
|
+
do tResponseList.append(tCallStructList(i))
|
|
291
|
+
}
|
|
292
|
+
quit tResponseList
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
Method dispatchSendRequestAsync(
|
|
296
|
+
pTarget,
|
|
297
|
+
pRequest,
|
|
298
|
+
pDescription)
|
|
299
|
+
{
|
|
300
|
+
set tSC = ..SendRequestAsync(pTarget,pRequest,pDescription)
|
|
301
|
+
if $$$ISERR(tSC) throw ##class(%Exception.StatusException).CreateFromStatus(tSC)
|
|
302
|
+
quit
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
ClassMethod OnGetConnections(
|
|
306
|
+
Output pArray As %String,
|
|
307
|
+
pItem As Ens.Config.Item)
|
|
308
|
+
{
|
|
309
|
+
// finds any settings of type Ens.DataType.ConfigName
|
|
310
|
+
Try {
|
|
311
|
+
do ..GetPropertyConnections(.pArray,pItem)
|
|
312
|
+
}
|
|
313
|
+
Catch ex {
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// Get settings
|
|
317
|
+
do pItem.GetModifiedSetting("%classpaths", .tClasspaths)
|
|
318
|
+
do pItem.GetModifiedSetting("%classname", .tClassname)
|
|
319
|
+
do pItem.GetModifiedSetting("%module", .tModule)
|
|
320
|
+
|
|
321
|
+
// try to instantiate class
|
|
322
|
+
if tClasspaths '="" {
|
|
323
|
+
set sys = ##class(%SYS.Python).Import("sys")
|
|
324
|
+
set delimiter = $s($system.Version.GetOS()="Windows":";",1:":")
|
|
325
|
+
set extraClasspaths = $tr(tClasspaths,delimiter,"|")
|
|
326
|
+
for i=1:1:$l(extraClasspaths,"|") {
|
|
327
|
+
set onePath = $p(extraClasspaths,"|",i)
|
|
328
|
+
set onePath = ##class(%File).NormalizeDirectory(onePath)
|
|
329
|
+
if onePath?1"$$IRISHOME"1P.E set onePath = $e($system.Util.InstallDirectory(),1,*-1)_$e(onePath,11,*)
|
|
330
|
+
if onePath'="" do sys.path.append(onePath)
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
set builtins = ##class(%SYS.Python).Import("builtins")
|
|
335
|
+
set module = ##class(%SYS.Python).Import(tModule)
|
|
336
|
+
set class = builtins.getattr(module, tClassname)
|
|
337
|
+
set tClass = class."__new__"(class)
|
|
338
|
+
|
|
339
|
+
set tPythonList = tClass."on_get_connections"()
|
|
340
|
+
set tPythonListLen = tPythonList."__len__"()
|
|
341
|
+
for i=0:1:(tPythonListLen-1) {
|
|
342
|
+
set tPythonItem = tPythonList."__getitem__"(i)
|
|
343
|
+
set pArray(tPythonItem) = ""
|
|
344
|
+
#; set ^AALog(pItem.Name,tPythonItem) = ""
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
quit
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
Method dispatchSendRequestAsyncNG(
|
|
351
|
+
pTarget,
|
|
352
|
+
pRequest,
|
|
353
|
+
pTimeout,
|
|
354
|
+
pDescription,
|
|
355
|
+
ByRef pMessageHeaderId,
|
|
356
|
+
ByRef pQueueName,
|
|
357
|
+
ByRef pEndTime) As %String
|
|
358
|
+
{
|
|
359
|
+
set tSC=$$$OK, tResponse=$$$NULLOREF
|
|
360
|
+
try {
|
|
361
|
+
|
|
362
|
+
set tTargetDispatchName=pTarget
|
|
363
|
+
set tTargetConfigName=$get($$$DispatchNameToConfigName(pTarget))
|
|
364
|
+
if tTargetConfigName="" set tSC=$$$EnsError($$$EnsErrBusinessDispatchNameNotRegistered,tTargetDispatchName) quit
|
|
365
|
+
set tTargetBusinessClass = $$$ConfigClassName(tTargetConfigName)
|
|
366
|
+
set tINVOCATION=$classmethod(tTargetBusinessClass,"%GetParameter","INVOCATION")
|
|
367
|
+
if (tINVOCATION'="Queue")&&(tINVOCATION'="InProc") set tSC=$$$ERROR($$$EnsErrParameterInvocationInvalid,tTargetBusinessClass) quit
|
|
368
|
+
|
|
369
|
+
quit:$$$ISERR(tSC)
|
|
370
|
+
;
|
|
371
|
+
set tStartTime=$zh
|
|
372
|
+
set:pTimeout'=-1 tEndTime=$zh+pTimeout
|
|
373
|
+
|
|
374
|
+
if tINVOCATION="InProc" {
|
|
375
|
+
set tTimeout=$s(pTimeout=-1:-1,1:tEndTime-$zh)
|
|
376
|
+
if (pTimeout'=-1)&&(tTimeout<0) quit
|
|
377
|
+
set tSC=..SendRequestSync(tTargetConfigName,pRequest,.tResponse,tTimeout,pDescription)
|
|
378
|
+
return tResponse
|
|
379
|
+
} elseif tINVOCATION="Queue" {
|
|
380
|
+
Set tSessionId=..%SessionId
|
|
381
|
+
Set tSuperSession = ..%SuperSession
|
|
382
|
+
Set tSC = ##class(Ens.MessageHeader).NewRequestMessage(.tRequestHeader,pRequest,.tSessionId,.tSuperSession) quit:$$$ISERR(tSC)
|
|
383
|
+
Set ..%SessionId=tSessionId
|
|
384
|
+
Set ..%SuperSession=tSuperSession
|
|
385
|
+
Set tRequestHeader.SourceConfigName = ..%ConfigName
|
|
386
|
+
Set tRequestHeader.TargetConfigName = tTargetConfigName
|
|
387
|
+
Set tRequestHeader.SourceBusinessType = $$$ConfigBusinessType($$$DispatchNameToConfigName(..%ConfigName))
|
|
388
|
+
Set tRequestHeader.TargetBusinessType = $$$ConfigBusinessType($$$DispatchNameToConfigName(tTargetConfigName))
|
|
389
|
+
Set tRequestHeader.TargetQueueName = $$$getConfigQueueName($$$DispatchNameToConfigName(tTargetConfigName),..%SessionId)
|
|
390
|
+
Set tRequestHeader.ReturnQueueName = $$$queueSyncCallQueueName
|
|
391
|
+
Set tRequestHeader.BusinessProcessId = ""
|
|
392
|
+
Set tRequestHeader.Priority = $$$eMessagePriorityAsync
|
|
393
|
+
Set tRequestHeader.Description = pDescription
|
|
394
|
+
Set tSC = ##class(Ens.Queue).Create($$$queueSyncCallQueueName) quit:$$$ISERR(tSC)
|
|
395
|
+
Set tSC = ##class(Ens.Queue).EnQueue(tRequestHeader) quit:$$$ISERR(tSC)
|
|
396
|
+
Set pMessageHeaderId = tRequestHeader.MessageId()
|
|
397
|
+
Set pQueueName = $$$queueSyncCallQueueName
|
|
398
|
+
Set:(pTimeout'=-1) pEndTime = tEndTime
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
catch {
|
|
402
|
+
set tSC = $$$EnsSystemError
|
|
403
|
+
}
|
|
404
|
+
quit tSC
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
Method dispatchIsRequestDone(
|
|
408
|
+
pTimeout,
|
|
409
|
+
pEndTime,
|
|
410
|
+
pQueueName,
|
|
411
|
+
pMessageHeaderId,
|
|
412
|
+
ByRef pResponse) As %Status
|
|
413
|
+
{
|
|
414
|
+
|
|
415
|
+
set tSC=$$$OK
|
|
416
|
+
try {
|
|
417
|
+
set tTimeout=$s(pTimeout=-1:-1,1:pEndTime-$zh)
|
|
418
|
+
|
|
419
|
+
set tSC = ##class(Ens.Queue).DeQueue($$$queueSyncCallQueueName,.tResponseHeader,tTimeout,.tIsTimedOut,0) Quit:$$$ISERR(tSC)
|
|
420
|
+
|
|
421
|
+
quit:$IsObject(tResponseHeader)=0
|
|
422
|
+
|
|
423
|
+
set tFound = $select(tResponseHeader.CorrespondingMessageId: pMessageHeaderId=tResponseHeader.CorrespondingMessageId, 1: 0)
|
|
424
|
+
if tFound=0 {
|
|
425
|
+
|
|
426
|
+
set tSC = ##class(Ens.Queue).EnQueue(tResponseHeader)
|
|
427
|
+
Kill $$$EnsActiveMessage($$$SystemName_":"_$Job)
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
|
|
431
|
+
if tIsTimedOut || ((pTimeout'=-1)&&(tTimeout<0)) {
|
|
432
|
+
|
|
433
|
+
do tResponseHeader.SetStatus($$$eMessageStatusDiscarded)
|
|
434
|
+
return $$$ERROR($$$EnsErrFailureTimeout, tTimeout, $$$StatusDisplayString(tSC), $$$CurrentClass)
|
|
435
|
+
}
|
|
436
|
+
if tResponseHeader.IsError {
|
|
437
|
+
|
|
438
|
+
do tResponseHeader.SetStatus($$$eMessageStatusCompleted)
|
|
439
|
+
return $$$EnsError($$$EnsErrGeneral,"Error message received: "_tResponseHeader.ErrorText)
|
|
440
|
+
|
|
441
|
+
}
|
|
442
|
+
if tResponseHeader.MessageBodyClassName'="" {
|
|
443
|
+
|
|
444
|
+
set tResponse = $classmethod(tResponseHeader.MessageBodyClassName,"%OpenId",tResponseHeader.MessageBodyId,,.tSC)
|
|
445
|
+
if '$IsObject(tResponse) return $$$EnsError($$$EnsErrGeneral,"Could not open MessageBody "_tResponseHeader.MessageBodyId_" for MessageHeader #"_tResponseHeader.%Id()_" with body class "_tResponseHeader.MessageBodyClassName_":"_$$$StatusDisplayString(tSC))
|
|
446
|
+
} else {
|
|
447
|
+
|
|
448
|
+
set tResponse=$$$NULLOREF
|
|
449
|
+
}
|
|
450
|
+
set pResponse=tResponse
|
|
451
|
+
do tResponseHeader.SetStatus($$$eMessageStatusCompleted)
|
|
452
|
+
set tSC = 2
|
|
453
|
+
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
catch ex {
|
|
457
|
+
set tSC = ex.AsStatus()
|
|
458
|
+
}
|
|
459
|
+
quit tSC
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
XData MessageMap
|
|
463
|
+
{
|
|
464
|
+
<MapItems>
|
|
465
|
+
<MapItem MessageType="IOP.Generator.Message.Start"><Method>OnMsgGeneratorStart</Method></MapItem>
|
|
466
|
+
<MapItem MessageType="IOP.Generator.Message.Stop"><Method>OnMsgGeneratorStop</Method></MapItem>
|
|
467
|
+
<MapItem MessageType="IOP.Generator.Message.Poll"><Method>OnMsgGeneratorPoll</Method></MapItem>
|
|
468
|
+
</MapItems>
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
Method OnMsgGeneratorStart(
|
|
472
|
+
pRequest As IOP.Generator.Message.Start,
|
|
473
|
+
Output pResponse As %Library.Persistent) As %Status
|
|
474
|
+
{
|
|
475
|
+
#dim tSC As %Status = $$$OK
|
|
476
|
+
try {
|
|
477
|
+
set pResponse = ..%class."_dispatch_generator_started"(pRequest)
|
|
478
|
+
} catch ex {
|
|
479
|
+
set tSC = ..DisplayTraceback(ex)
|
|
480
|
+
}
|
|
481
|
+
quit tSC
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
Method OnMsgGeneratorStop(
|
|
485
|
+
pRequest As IOP.Generator.Message.Stop,
|
|
486
|
+
Output pResponse As %Library.Persistent) As %Status
|
|
487
|
+
{
|
|
488
|
+
#dim tSC As %Status = $$$OK
|
|
489
|
+
|
|
490
|
+
try {
|
|
491
|
+
set pResponse = ..%class."_dispatch_generator_stopped"(pRequest)
|
|
492
|
+
} catch ex {
|
|
493
|
+
set tSC = ..DisplayTraceback(ex)
|
|
494
|
+
}
|
|
495
|
+
quit tSC
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
Method OnMsgGeneratorPoll(
|
|
499
|
+
pPollIn As IOP.Generator.Message.Poll,
|
|
500
|
+
Output pResponse As %Library.Persistent) As %Status
|
|
501
|
+
{
|
|
502
|
+
#dim tSC As %Status = $$$OK
|
|
503
|
+
set tSC = $$$OK
|
|
504
|
+
try {
|
|
505
|
+
set pResponse = ..%class."_dispatch_generator_poll"()
|
|
506
|
+
} catch ex {
|
|
507
|
+
set tSC = ..DisplayTraceback(ex)
|
|
508
|
+
}
|
|
509
|
+
quit tSC
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
Method InitializePythonClass() As %Status [ Private ]
|
|
513
|
+
{
|
|
514
|
+
set tSC = $$$OK
|
|
515
|
+
try {
|
|
516
|
+
// Check if module is already imported
|
|
517
|
+
set sys = ##class(%SYS.Python).Import("sys")
|
|
518
|
+
set module = sys.modules.get(..%module, $$$NULLOREF)
|
|
519
|
+
|
|
520
|
+
if $isObject(module) {
|
|
521
|
+
$$$LOGINFO("Module "_..%module_" is already imported in sys.modules")
|
|
522
|
+
set ..%class = ..CreateClassInstance(module)
|
|
523
|
+
} else {
|
|
524
|
+
// Setup classpaths if specified
|
|
525
|
+
if ..%classpaths '= "" {
|
|
526
|
+
do ..SetupClasspaths()
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
// Import module and create class instance
|
|
530
|
+
set module = ##class(%SYS.Python).Import(..%module)
|
|
531
|
+
set ..%class = ..CreateClassInstance(module)
|
|
532
|
+
}
|
|
533
|
+
} catch ex {
|
|
534
|
+
set tSC = ex.AsStatus()
|
|
535
|
+
}
|
|
536
|
+
quit tSC
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
Method CreateClassInstance(module As %SYS.Python) As %SYS.Python [ Private ]
|
|
540
|
+
{
|
|
541
|
+
set builtins = ##class(%SYS.Python).Import("builtins")
|
|
542
|
+
set class = builtins.getattr(module, ..%classname)
|
|
543
|
+
quit class."__new__"(class)
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
Method SetupClasspaths() [ Private ]
|
|
547
|
+
{
|
|
548
|
+
set delimiter = $s($system.Version.GetOS()="Windows":";",1:":")
|
|
549
|
+
set extraClasspaths = $tr(..%classpaths, delimiter, "|")
|
|
550
|
+
|
|
551
|
+
for i=1:1:$l(extraClasspaths,"|") {
|
|
552
|
+
set onePath = $p(extraClasspaths,"|",i)
|
|
553
|
+
set onePath = ##class(%File).NormalizeDirectory(onePath)
|
|
554
|
+
do ..SetPythonPath(onePath)
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
Method SetIrisHandles() [ Private ]
|
|
559
|
+
{
|
|
560
|
+
if ..%Extends("IOP.InboundAdapter") || ..%Extends("IOP.OutboundAdapter") {
|
|
561
|
+
do ..%class."_set_iris_handles"($this, ..BusinessHost)
|
|
562
|
+
} elseif $this.%Extends("IOP.BusinessProcess") {
|
|
563
|
+
do ..%class."_set_iris_handles"($this, $$$NULLOREF)
|
|
564
|
+
} else {
|
|
565
|
+
do ..%class."_set_iris_handles"($this, ..Adapter)
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
}
|
iop/cls/IOP/Director.cls
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/* Copyright (c) 2021 by InterSystems Corporation.
|
|
2
|
+
Cambridge, Massachusetts, U.S.A. All rights reserved.
|
|
3
|
+
Confidential property of InterSystems Corporation. */
|
|
4
|
+
|
|
5
|
+
Include (%occInclude, Ensemble)
|
|
6
|
+
|
|
7
|
+
Class IOP.Director [ Inheritance = right, ProcedureBlock, System = 4 ]
|
|
8
|
+
{
|
|
9
|
+
|
|
10
|
+
ClassMethod dispatchCreateBusinessService(pTargetDispatchName As %String) As Ens.BusinessService
|
|
11
|
+
{
|
|
12
|
+
set tSC = ##class(Ens.Director).CreateBusinessService(pTargetDispatchName,.service)
|
|
13
|
+
|
|
14
|
+
// Hack to prevent job to be registered in the production
|
|
15
|
+
do ##class(Ens.Job).UnRegister(pTargetDispatchName,$JOB)
|
|
16
|
+
|
|
17
|
+
if $$$ISERR(tSC) throw ##class(%Exception.StatusException).CreateFromStatus(tSC)
|
|
18
|
+
|
|
19
|
+
quit service
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
ClassMethod dispatchListProductions() As %String
|
|
23
|
+
{
|
|
24
|
+
// Loop over the productions in this namespace
|
|
25
|
+
Set tRS = ##class(%ResultSet).%New("Ens.Config.Production:ProductionStatus")
|
|
26
|
+
If '$IsObject(tRS) Set tSC = %objlasterror Quit
|
|
27
|
+
|
|
28
|
+
Set tSC = tRS.Execute()
|
|
29
|
+
Quit:$$$ISERR(tSC)
|
|
30
|
+
|
|
31
|
+
set tDict = ##class(%SYS.Python).Import("builtins").dict()
|
|
32
|
+
|
|
33
|
+
While (tRS.Next()) {
|
|
34
|
+
Set tProduction = tRS.Data("Production")
|
|
35
|
+
Set tInfo = ##class(%SYS.Python).Import("builtins").dict()
|
|
36
|
+
do tInfo."__setitem__"("Status",tRS.Data("Status"))
|
|
37
|
+
do tInfo."__setitem__"("LastStartTime",tRS.Data("LastStartTime"))
|
|
38
|
+
do tInfo."__setitem__"("LastStopTime",tRS.Data("LastStopTime"))
|
|
39
|
+
do tInfo."__setitem__"("AutoStart",$G(^Ens.AutoStart)=tProduction)
|
|
40
|
+
do tDict."__setitem__"(tProduction,tInfo)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
Kill tRS
|
|
44
|
+
|
|
45
|
+
return tDict
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
ClassMethod StatusProduction() As %String
|
|
49
|
+
{
|
|
50
|
+
Set sc = $$$OK
|
|
51
|
+
Set tInfo = ##class(%SYS.Python).Import("builtins").dict()
|
|
52
|
+
$$$ThrowOnError(##class(Ens.Director).GetProductionStatus(.tProdName,.tStatus))
|
|
53
|
+
do tInfo."__setitem__"("Production",tProdName)
|
|
54
|
+
do tInfo."__setitem__"("Status",$CASE(tStatus,$$$eProductionStateRunning:"running",
|
|
55
|
+
$$$eProductionStateStopped:"stopped",
|
|
56
|
+
$$$eProductionStateSuspended:"suspended",
|
|
57
|
+
$$$eProductionStateTroubled:"toubled",
|
|
58
|
+
:"unknown"))
|
|
59
|
+
// Get if production needs update
|
|
60
|
+
set tNeedsUpdate = ##class(Ens.Director).ProductionNeedsUpdate(.tMsgUpdate)
|
|
61
|
+
do tInfo."__setitem__"("NeedsUpdate",tNeedsUpdate)
|
|
62
|
+
// If needs update get message
|
|
63
|
+
if tNeedsUpdate {
|
|
64
|
+
do tInfo."__setitem__"("UpdateMessage",tMsgUpdate)
|
|
65
|
+
}
|
|
66
|
+
// Get last start time
|
|
67
|
+
Return tInfo
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Class IOP.DuplexOperation Extends IOP.PrivateSessionDuplex
|
|
2
|
+
{
|
|
3
|
+
|
|
4
|
+
ClassMethod OnBusinessType(pItem As Ens.Config.Item) As %Integer
|
|
5
|
+
{
|
|
6
|
+
Quit $$$eHostTypeOperation
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
XData MessageMap
|
|
10
|
+
{
|
|
11
|
+
<MapItems>
|
|
12
|
+
<MapItem MessageType="Ens.Request"><Method>OnMessage</Method></MapItem>
|
|
13
|
+
</MapItems>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
Method OnMessage(
|
|
17
|
+
request As %Library.Persistent,
|
|
18
|
+
Output response As %Library.Persistent) As %Status
|
|
19
|
+
{
|
|
20
|
+
set tSC = $$$OK
|
|
21
|
+
try {
|
|
22
|
+
set response = ..%class."_dispatch_on_message"(request)
|
|
23
|
+
} catch ex {
|
|
24
|
+
set tSC = ex.AsStatus()
|
|
25
|
+
}
|
|
26
|
+
quit tSC
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|