iris-pex-embedded-python 3.0.1b8__py3-none-any.whl → 3.0.1b10__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.

Potentially problematic release.


This version of iris-pex-embedded-python might be problematic. Click here for more details.

iop/_business_host.py CHANGED
@@ -1,3 +1,4 @@
1
+ import asyncio
1
2
  import datetime
2
3
  import pickle
3
4
  import codecs
@@ -133,7 +134,6 @@ class _BusinessHost(_Common):
133
134
  Raises:
134
135
  TypeError: if request is not of type Message or IRISObject.
135
136
  """
136
-
137
137
  return self.iris_handle.dispatchSendRequestSync(target,request,timeout,description)
138
138
 
139
139
  @input_serialzer_param(1,'request')
@@ -151,6 +151,50 @@ class _BusinessHost(_Common):
151
151
  """
152
152
 
153
153
  return self.iris_handle.dispatchSendRequestAsync(target,request,description)
154
+
155
+ async def send_request_async_ng(self, target, request, timeout=-1, description=None):
156
+ """ Send the specified message to the target business process or business operation asynchronously.
157
+ Parameters:
158
+ target: a string that specifies the name of the business process or operation to receive the request.
159
+ The target is the name of the component as specified in the Item Name property in the production definition, not the class name of the component.
160
+ request: specifies the message to send to the target. The request is an instance of IRISObject or of a subclass of Message.
161
+ If the target is a built-in ObjectScript component, you should use the IRISObject class. The IRISObject class enables the PEX framework to convert the message to a class supported by the target.
162
+ description: an optional string parameter that sets a description property in the message header. The default is None.
163
+ """
164
+ return await _send_request_async_ng(target, request, timeout ,description, self)
165
+
166
+ def send_multi_request_sync(self, target_request:list, timeout=-1, description=None)->list:
167
+ """ Send the specified list of tuple (target,request) to business process or business operation synchronously.
168
+
169
+ Parameters:
170
+ target_request: a list of tuple (target,request) that specifies the name of the business process or operation to receive the request.
171
+ The target is the name of the component as specified in the Item Name property in the production definition, not the class name of the component.
172
+ The request is either an instance of a class that is a subclass of Message class or of IRISObject class.
173
+ timeout: an optional integer that specifies the number of seconds to wait before treating the send request as a failure. The default value is -1, which means wait forever.
174
+ description: an optional string parameter that sets a description property in the message header. The default is None.
175
+ Returns:
176
+ the list of tuple (target,request,response,status).
177
+ """
178
+ # create a list of iris.Ens.CallStructure for each target_request
179
+ call_list = []
180
+ for target,request in target_request:
181
+ call = iris.cls("Ens.CallStructure")._New()
182
+ call.TargetDispatchName = target
183
+ call.Request = self._dispatch_serializer(request)
184
+ call_list.append(call)
185
+ # call the dispatchSendMultiRequestSync method
186
+ response_list = self.iris_handle.dispatchSendRequestSyncMultiple(call_list,timeout)
187
+ # create a list of tuple (target,request,response,status)
188
+ result = []
189
+ for i in range(len(target_request)):
190
+ result.append(
191
+ (target_request[i][0],
192
+ target_request[i][1],
193
+ self._dispatch_deserializer(response_list[i].Response),
194
+ response_list[i].ResponseCode
195
+ ))
196
+ return result
197
+
154
198
 
155
199
  def _serialize_pickle_message(self,message):
156
200
  """ Converts a python dataclass message into an iris iop.message.
@@ -517,3 +561,60 @@ class IrisJSONDecoder(json.JSONDecoder):
517
561
  else:
518
562
  ret[key] = value
519
563
  return ret
564
+
565
+ class _send_request_async_ng(asyncio.Future):
566
+
567
+ _message_header_id = 0
568
+ _queue_name = ""
569
+ _end_time = 0
570
+ _response = None
571
+ _done = False
572
+
573
+ def __init__(self, target, request, timeout=-1, description=None, host=None):
574
+ super().__init__()
575
+ self.target = target
576
+ self.request = request
577
+ self.timeout = timeout
578
+ self.description = description
579
+ self.host = host
580
+ self._iris_handle = host.iris_handle
581
+ asyncio.create_task(self.send())
582
+
583
+ async def send(self):
584
+ # init parameters
585
+ message_header_id = iris.ref()
586
+ queue_name = iris.ref()
587
+ end_time = iris.ref()
588
+ request = self.host._dispatch_serializer(self.request)
589
+
590
+ # send request
591
+ self._iris_handle.dispatchSendRequestAsyncNG(
592
+ self.target, request, self.timeout, self.description,
593
+ message_header_id, queue_name, end_time)
594
+
595
+ # get byref values
596
+ self._message_header_id = message_header_id.value
597
+ self._queue_name = queue_name.value
598
+ self._end_time = end_time.value
599
+
600
+ while not self._done:
601
+ await asyncio.sleep(0.1)
602
+ self.is_done()
603
+
604
+ self.set_result(self._response)
605
+
606
+ def is_done(self):
607
+ response = iris.ref()
608
+ status = self._iris_handle.dispatchIsRequestDone(self.timeout, self._end_time,
609
+ self._queue_name, self._message_header_id,
610
+ response)
611
+
612
+ self._response = self.host._dispatch_deserializer(response.value)
613
+
614
+ if status == 2: # message found
615
+ self._done = True
616
+ elif status == 1: # message not found
617
+ pass
618
+ else:
619
+ self._done = True
620
+ self.set_exception(RuntimeError(iris.system.Status.GetOneStatusText(status)))
iop/cls/IOP/Common.cls CHANGED
@@ -139,22 +139,45 @@ Method SetPropertyValues()
139
139
  }
140
140
 
141
141
  Method dispatchSendRequestSync(
142
- target,
143
- request,
142
+ pTarget,
143
+ pRequest,
144
144
  timeout,
145
- description) As %String
145
+ pDescription) As %String
146
146
  {
147
- set tSC = ..SendRequestSync(target,request,.objResponse,timeout,description)
147
+ set tSC = ..SendRequestSync(pTarget,pRequest,.objResponse,timeout,pDescription)
148
148
  if $$$ISERR(tSC) throw ##class(%Exception.StatusException).CreateFromStatus(tSC)
149
149
  quit $g(objResponse)
150
150
  }
151
151
 
152
+ Method dispatchSendRequestSyncMultiple(
153
+ pCallStructList As %List,
154
+ pTimeout As %Numeric = -1) As %List
155
+ {
156
+ set builtins = ##class(%SYS.Python).Import("builtins")
157
+ // Convert %List to multidimensional array
158
+ set tCallStructList=builtins.len(pCallStructList)
159
+ for i=0:1:builtins.len(pCallStructList)-1 {
160
+ set tCallStructList(i+1) = pCallStructList."__getitem__"(i)
161
+ }
162
+
163
+ set tSC = ..SendRequestSyncMultiple(.tCallStructList,pTimeout)
164
+ if $$$ISERR(tSC) throw ##class(%Exception.StatusException).CreateFromStatus(tSC)
165
+
166
+ // Convert multidimensional array to Python list
167
+ set tResponseList = builtins.list()
168
+
169
+ for i=1:1:tCallStructList {
170
+ do tResponseList.append(tCallStructList(i))
171
+ }
172
+ quit tResponseList
173
+ }
174
+
152
175
  Method dispatchSendRequestAsync(
153
- target,
154
- request,
155
- description)
176
+ pTarget,
177
+ pRequest,
178
+ pDescription)
156
179
  {
157
- set tSC = ..SendRequestAsync(target,request,description)
180
+ set tSC = ..SendRequestAsync(pTarget,pRequest,pDescription)
158
181
  if $$$ISERR(tSC) throw ##class(%Exception.StatusException).CreateFromStatus(tSC)
159
182
  quit
160
183
  }
@@ -200,4 +223,116 @@ ClassMethod OnGetConnections(
200
223
  quit
201
224
  }
202
225
 
226
+ Method dispatchSendRequestAsyncNG(
227
+ pTarget,
228
+ pRequest,
229
+ pTimeout,
230
+ pDescription,
231
+ ByRef pMessageHeaderId,
232
+ ByRef pQueueName,
233
+ ByRef pEndTime) As %String
234
+ {
235
+ set tSC=$$$OK, tResponse=$$$NULLOREF
236
+ try {
237
+
238
+ set tTargetDispatchName=pTarget
239
+ set tTargetConfigName=$get($$$DispatchNameToConfigName(pTarget))
240
+ if tTargetConfigName="" set tSC=$$$EnsError($$$EnsErrBusinessDispatchNameNotRegistered,tTargetDispatchName) quit
241
+ set tTargetBusinessClass = $$$ConfigClassName(tTargetConfigName)
242
+ set tINVOCATION=$classmethod(tTargetBusinessClass,"%GetParameter","INVOCATION")
243
+ if (tINVOCATION'="Queue")&&(tINVOCATION'="InProc") set tSC=$$$ERROR($$$EnsErrParameterInvocationInvalid,tTargetBusinessClass) quit
244
+
245
+ quit:$$$ISERR(tSC)
246
+ ;
247
+ set tStartTime=$zh
248
+ set:pTimeout'=-1 tEndTime=$zh+pTimeout
249
+
250
+ if tINVOCATION="InProc" {
251
+ set tTimeout=$s(pTimeout=-1:-1,1:tEndTime-$zh)
252
+ if (pTimeout'=-1)&&(tTimeout<0) quit
253
+ set tSC=..SendRequestSync(tTargetConfigName,pRequest,.tResponse,tTimeout,pDescription)
254
+ return tResponse
255
+ } elseif tINVOCATION="Queue" {
256
+ Set tSessionId=..%SessionId
257
+ Set tSuperSession = ..%SuperSession
258
+ Set tSC = ##class(Ens.MessageHeader).NewRequestMessage(.tRequestHeader,pRequest,.tSessionId,.tSuperSession) quit:$$$ISERR(tSC)
259
+ Set ..%SessionId=tSessionId
260
+ Set ..%SuperSession=tSuperSession
261
+ Set tRequestHeader.SourceConfigName = ..%ConfigName
262
+ Set tRequestHeader.TargetConfigName = tTargetConfigName
263
+ Set tRequestHeader.SourceBusinessType = $$$ConfigBusinessType($$$DispatchNameToConfigName(..%ConfigName))
264
+ Set tRequestHeader.TargetBusinessType = $$$ConfigBusinessType($$$DispatchNameToConfigName(tTargetConfigName))
265
+ Set tRequestHeader.TargetQueueName = $$$getConfigQueueName($$$DispatchNameToConfigName(tTargetConfigName),..%SessionId)
266
+ Set tRequestHeader.ReturnQueueName = $$$queueSyncCallQueueName
267
+ Set tRequestHeader.BusinessProcessId = ""
268
+ Set tRequestHeader.Priority = $$$eMessagePriorityAsync
269
+ Set tRequestHeader.Description = pDescription
270
+ Set tSC = ##class(Ens.Queue).Create($$$queueSyncCallQueueName) quit:$$$ISERR(tSC)
271
+ Set tSC = ##class(Ens.Queue).EnQueue(tRequestHeader) quit:$$$ISERR(tSC)
272
+ Set pMessageHeaderId = tRequestHeader.MessageId()
273
+ Set pQueueName = $$$queueSyncCallQueueName
274
+ Set:(pTimeout'=-1) pEndTime = tEndTime
275
+ }
276
+ }
277
+ catch {
278
+ set tSC = $$$EnsSystemError
279
+ }
280
+ quit tSC
281
+ }
282
+
283
+ Method dispatchIsRequestDone(
284
+ pTimeout,
285
+ pEndTime,
286
+ pQueueName,
287
+ pMessageHeaderId,
288
+ ByRef pResponse) As %Status
289
+ {
290
+
291
+ set tSC=$$$OK
292
+ try {
293
+ set tTimeout=$s(pTimeout=-1:-1,1:pEndTime-$zh)
294
+
295
+ set tSC = ##class(Ens.Queue).DeQueue($$$queueSyncCallQueueName,.tResponseHeader,tTimeout,.tIsTimedOut,0) Quit:$$$ISERR(tSC)
296
+
297
+ quit:$IsObject(tResponseHeader)=0
298
+
299
+ set tFound = $select(tResponseHeader.CorrespondingMessageId: pMessageHeaderId=tResponseHeader.CorrespondingMessageId, 1: 0)
300
+ if tFound=0 {
301
+
302
+ set tSC = ##class(Ens.Queue).EnQueue(tResponseHeader)
303
+ Kill $$$EnsActiveMessage($$$SystemName_":"_$Job)
304
+ }
305
+ else {
306
+
307
+ if tIsTimedOut || ((pTimeout'=-1)&&(tTimeout<0)) {
308
+
309
+ do tResponseHeader.SetStatus($$$eMessageStatusDiscarded)
310
+ return $$$ERROR($$$EnsErrFailureTimeout, tTimeout, $$$StatusDisplayString(tSC), $$$CurrentClass)
311
+ }
312
+ if tResponseHeader.IsError {
313
+
314
+ do tResponseHeader.SetStatus($$$eMessageStatusCompleted)
315
+ return $$$EnsError($$$EnsErrGeneral,"Error message received: "_tResponseHeader.ErrorText)
316
+
317
+ }
318
+ if tResponseHeader.MessageBodyClassName'="" {
319
+
320
+ set tResponse = $classmethod(tResponseHeader.MessageBodyClassName,"%OpenId",tResponseHeader.MessageBodyId,,.tSC)
321
+ if '$IsObject(tResponse) return $$$EnsError($$$EnsErrGeneral,"Could not open MessageBody "_tResponseHeader.MessageBodyId_" for MessageHeader #"_tResponseHeader.%Id()_" with body class "_tResponseHeader.MessageBodyClassName_":"_$$$StatusDisplayString(tSC))
322
+ } else {
323
+
324
+ set tResponse=$$$NULLOREF
325
+ }
326
+ set pResponse=tResponse
327
+ do tResponseHeader.SetStatus($$$eMessageStatusCompleted)
328
+ set tSC = 2
329
+
330
+ }
331
+ }
332
+ catch ex {
333
+ set tSC = ex.AsStatus()
334
+ }
335
+ quit tSC
336
+ }
337
+
203
338
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: iris_pex_embedded_python
3
- Version: 3.0.1b8
3
+ Version: 3.0.1b10
4
4
  Summary: Iris Interoperability based on Embedded Python
5
5
  Author-email: grongier <guillaume.rongier@intersystems.com>
6
6
  License: MIT License
@@ -92,7 +92,7 @@ intersystems_iris/pex/_OutboundAdapter.py,sha256=ao2Ubbta2DcrQGdzDUD_j1Zsk8bvUfc
92
92
  intersystems_iris/pex/__init__.py,sha256=l_I1dpnluWawbFrGMDC0GLHpuHwjbpd-nho8otFX6TE,1379
93
93
  iop/__init__.py,sha256=zHFF0Znipx1fwHYUEBZjNOYoZH1ro7z4IgYDU32kdn0,1067
94
94
  iop/__main__.py,sha256=pQzVtkDhAeI6dpNRC632dVk2SGZZIEDwDufdgZe8VWs,98
95
- iop/_business_host.py,sha256=IRxhn1vXeMqlIztugvZNUxcBrM1gTHeGbjJGafrXbHQ,22383
95
+ iop/_business_host.py,sha256=-oarCQ-99yYY_DOUCxotcWIVyiPnfpxKb38RBywDZw8,27401
96
96
  iop/_business_operation.py,sha256=P824IzO89LCKnoNHZk64OZBDHcomHpjhKmMT89bS6TI,3500
97
97
  iop/_business_process.py,sha256=F4NIQcwQ5u8yiAPpaN14OAXxbKJsRAGm5S4lrbgA3oI,13296
98
98
  iop/_business_service.py,sha256=sX8J-2-0Go6uIuPYa0A5N9Nn9rY5lV6a05v4q78qDC8,3726
@@ -109,7 +109,7 @@ iop/_utils.py,sha256=3rhO33PLZ1ESJiboQFwfIGUvHV7RBSbq6A2CPyMaojA,16269
109
109
  iop/cls/IOP/BusinessOperation.cls,sha256=lrymqZ8wHl5kJjXwdjbQVs5sScV__yIWGh-oGbiB_X0,914
110
110
  iop/cls/IOP/BusinessProcess.cls,sha256=s3t38w1ykHqM26ETcbCYLt0ocjZyVVahm-_USZkuJ1E,2855
111
111
  iop/cls/IOP/BusinessService.cls,sha256=7ebn32J9PiZXUgXuh5Xxm_7X6zHBiqkJr9c_dWxbPO8,1021
112
- iop/cls/IOP/Common.cls,sha256=CFgA0qxy0Iz5FRpPHyz8_cyKMyImuKlLsx0JMjCOEGQ,5718
112
+ iop/cls/IOP/Common.cls,sha256=vYTnsL-ch-vTjpigBtwOHgrnOQMmuTkqXT9F-vWE650,11068
113
113
  iop/cls/IOP/Director.cls,sha256=DlxyFvsJjB1FVImFVNkRpQy7XXIMRoDZOLpEdMlwgOU,1885
114
114
  iop/cls/IOP/InboundAdapter.cls,sha256=GeoCm6q5HcLJ5e4VxgqXiErJXqolBbpKwpunaNzpvjU,610
115
115
  iop/cls/IOP/Message.cls,sha256=ecLsPKUcW0jUx1tDpyrMDlaTgrs61L8ecuuZTCbCxV8,8209
@@ -135,9 +135,9 @@ iris/iris_ipm.pyi,sha256=j7CNUZcjeDu5sgeWUZJO_Qi4vQmHh6aD-jPWv8OdoUs,374
135
135
  iris/iris_utils.py,sha256=kg80O3yRpHIutM-mCyr4xCeTvKWPE-Kai-b6Dxw4vQ4,9882
136
136
  irisnative/_IRISNative.py,sha256=HQ4nBhc8t8_5OtxdMG-kx1aa-T1znf2I8obZOPLOPzg,665
137
137
  irisnative/__init__.py,sha256=6YmvBLQSURsCPKaNg7LK-xpo4ipDjrlhKuwdfdNb3Kg,341
138
- iris_pex_embedded_python-3.0.1b8.dist-info/LICENSE,sha256=rZSiBFId_sfbJ6RL0GjjPX-InNLkNS9ou7eQsikciI8,1089
139
- iris_pex_embedded_python-3.0.1b8.dist-info/METADATA,sha256=I5HsCWqTkWSFg5qYk_55pnFSNBGfGS_q8Uh8UjVnaNU,49482
140
- iris_pex_embedded_python-3.0.1b8.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
141
- iris_pex_embedded_python-3.0.1b8.dist-info/entry_points.txt,sha256=pj-i4LSDyiSP6xpHlVjMCbg1Pik7dC3_sdGY3Yp9Vhk,38
142
- iris_pex_embedded_python-3.0.1b8.dist-info/top_level.txt,sha256=jkWtvFKOp1Q-uO_VpGpfx5TcW7DS39z1liOAVp6zLig,47
143
- iris_pex_embedded_python-3.0.1b8.dist-info/RECORD,,
138
+ iris_pex_embedded_python-3.0.1b10.dist-info/LICENSE,sha256=rZSiBFId_sfbJ6RL0GjjPX-InNLkNS9ou7eQsikciI8,1089
139
+ iris_pex_embedded_python-3.0.1b10.dist-info/METADATA,sha256=Acj3OVXl5xHrFP2c3pea3zJ1_8Ac1n1aB16KurNbIg8,49483
140
+ iris_pex_embedded_python-3.0.1b10.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
141
+ iris_pex_embedded_python-3.0.1b10.dist-info/entry_points.txt,sha256=pj-i4LSDyiSP6xpHlVjMCbg1Pik7dC3_sdGY3Yp9Vhk,38
142
+ iris_pex_embedded_python-3.0.1b10.dist-info/top_level.txt,sha256=jkWtvFKOp1Q-uO_VpGpfx5TcW7DS39z1liOAVp6zLig,47
143
+ iris_pex_embedded_python-3.0.1b10.dist-info/RECORD,,