Skip to content

Commit 9e0f860

Browse files
committed
loop
1 parent c38c34b commit 9e0f860

File tree

1 file changed

+43
-41
lines changed

1 file changed

+43
-41
lines changed

bpmn_types.py

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
BPMN_MAPPINGS = {}
2525

2626
timeout = ClientTimeout(sock_connect=5)
27-
client_session = ClientSession(timeout=timeout)
2827

2928

3029
def bpmn_tag(tag):
@@ -254,49 +253,52 @@ async def run_connector(self, variables, instance_id):
254253
)
255254

256255
# Check method and make request
257-
async with aiohttp.ClientSession() as session:
258-
async with session.get('http://httpbin.org/get') as resp:
259-
print(resp.status)
260-
print(await resp.text())
261-
print(await resp.text())
262-
print("test")
263-
return
264-
if method := self.connector_fields["input_variables"].get("method") or "GET":
265-
if method == "POST":
266-
call_function = client_session.post
267-
elif method == "PATCH":
268-
call_function = client_session.patch
269-
else:
270-
call_function = client_session.get
271-
if not isinstance(data, dict):
272-
data = dict(data)
273-
response = await call_function(
274-
url,
275-
params=parameters,
276-
json=data,
277-
headers={'content-type': 'application/json'}
278-
)
279-
if response.status not in (200, 201):
280-
raise Exception(response.text)
256+
async with aiohttp.ClientSession(timeout=timeout) as client_session:
257+
if method := self.connector_fields["input_variables"].get("method") or "GET":
258+
if method == "POST":
259+
call_function = client_session.post
260+
elif method == "PATCH":
261+
call_function = client_session.patch
262+
else:
263+
call_function = client_session.get
264+
if not isinstance(data, dict):
265+
data = dict(data)
266+
response = await call_function(
267+
url,
268+
params=parameters,
269+
json=data,
270+
headers={'content-type': 'application/json'}
271+
)
272+
if response.status not in (200, 201):
273+
raise Exception(response.text)
274+
275+
r = {}
276+
try:
277+
r = await response.json()
278+
except Exception as e:
279+
print("error")
280+
if not isinstance(e, ContentTypeError):
281+
raise e
282+
283+
# Check for output variables
284+
285+
if self.output_variables:
286+
for key in self.output_variables:
287+
value = self.output_variables.get(key)
288+
if len(value) > 0:
289+
variables[key] = parse_expression(expression=value, process_variables=r)
290+
if key in r:
291+
variables[key] = r[key]
292+
print(variables)
293+
return r
294+
295+
296+
297+
298+
281299

282-
r = {}
283-
try:
284-
r = await response.json()
285-
except Exception as e:
286-
print("error")
287-
if not isinstance(e, ContentTypeError):
288-
raise e
289300

290-
# Check for output variables
291301

292-
if self.output_variables:
293-
for key in self.output_variables:
294-
value = self.output_variables.get(key)
295-
if len(value) > 0:
296-
variables[key] = parse_expression(expression=value, process_variables=r)
297-
if key in r:
298-
variables[key] = r[key]
299-
print(variables)
300302

301303
async def run(self, variables, instance_id):
302304

0 commit comments

Comments
 (0)