forked from IBM/python-itoolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathisql_rest_async.py
32 lines (31 loc) · 929 Bytes
/
isql_rest_async.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
try:
import queue
except ImportError:
import Queue as queue
import threading
import urllib
from itoolkit.transport import HttpTransport
from itoolkit import *
class iDB2Async():
def __init__(self, isql):
self.itran = HttpTransport('http://yips.idevcloud.com/cgi-bin/xmlcgi.pgm','*NONE','*NONE')
self.itool = iToolKit()
self.itool.add(iSqlQuery('iqry', isql))
self.itool.add(iSqlFetch('ifch'))
self.itool.add(iSqlFree('ifre'))
def go(self):
self.itool.call(self.itran)
return self.itool.dict_out('ifch')
def get_url(q, icmd):
q.put(iDB2Async(icmd).go())
thedb2s = ["select CUSNUM from QIWS/QCUSTCDT where LSTNAM='Jones'",
"select CUSNUM from QIWS/QCUSTCDT where LSTNAM='Johnson'"]
q = queue.Queue()
for u in thedb2s:
t = threading.Thread(target=get_url, args = (q,u))
t.daemon = True
t.start()
# q.join()
for u in thedb2s:
s = q.get()
print(s)