python connect_pool.py
Chiqarilgan so'rov natijalarini ko'rsatadi, chunki har bir ip mustaqil ravishda qiymatlarni oladi. Interleaving tartibi yugurishdan yugurishgacha farq qilishi mumkin.
Review connect_pool2.py, unda iplar soni bo'yicha halqa mavjud, har bir iteratsiya Query()usulni chaqiradi :
import cx_Oracle
import iplari
import db_config
hovuz = cx_Oracle.SessionPool(db_config.user, db_config.pw, db_config.dsn,
min = 2, maksimal = 5, o'sish = 1, tishli = rost,
getmode = cx_Oracle.SPOOL_ATTRVAL_WAIT)
def Query():
con = pool.acquire()
cur = con.cursor()
diapazondagi i uchun(4):
cur.execute("dualdan myseq.nextval-ni tanlang")
seqval, = cur.fetchone()
print("Thread", threading.current_thread().name, "olish sequence=", seqval)
Do'stlaringiz bilan baham: |