def fnThreadLoop(i, queue, lock): s = requests.Session() while True: #exit Thread when detect signal to quit. while libextra.fnExitNow(): try: r = queue.get_nowait() break except: #libextra.fnQueueEmpty(1,lock) time.sleep(0.1) continue if libextra.fnExitNow() == False: break id = r[0] (status, gw_resp, log_msg) = fnJOB_CallAPI(s,r) gw_resp = pymysql.escape_string(gw_resp) #if (log_msg != ''): # print(log_msg) QueueUpdate.put((id,status,gw_resp)) queue.task_done()
def fnThreadLoop(i, queue, lock): s = requests.Session() while True: #exit Thread when detect signal to quit. while libextra.fnExitNow(): try: r = queue.get_nowait() break except: #libextra.fnQueueEmpty(1,lock) time.sleep(0.1) continue if libextra.fnExitNow() == False: break id = r[0] (status, gw_resp, log_msg) = fnJOB_CallAPI(s, r) gw_resp = pymysql.escape_string(gw_resp) #if (log_msg != ''): # print(log_msg) QueueUpdate.put((id, status, gw_resp)) queue.task_done()
return(True) except Exception as e: logg.error('Loop4Ever Exception (MySQL conn problem) -> ', exc_info=True) cur = libextra.fnMySQLConnect() time.sleep(5) # # STEP 5 - GET DATA FROM MYSQL # while True: while (libextra.fnQueueControl(lock,0) > 0) & (libextra.fnExitNow(True)): while fnUpdateRows(cur): pass time.sleep(0.1) while fnUpdateRows(cur): pass if libextra.fnExitNow() == False: break sql = " SELECT id, bnum, anum, carrier, text" \ " FROM MessageQueue " \ " WHERE status = 0" \ " and ((now() >= din_sched) or (din_sched is null))" \
return (True) except Exception as e: logg.error('Loop4Ever Exception (MySQL conn problem) -> ', exc_info=True) cur = libextra.fnMySQLConnect() time.sleep(5) # # STEP 5 - GET DATA FROM MYSQL # while True: while (libextra.fnQueueControl(lock, 0) > 0) & (libextra.fnExitNow(True)): while fnUpdateRows(cur): pass time.sleep(0.1) while fnUpdateRows(cur): pass if libextra.fnExitNow() == False: break sql = " SELECT id, bnum, anum, carrier, text" \ " FROM MessageQueue " \ " WHERE status = 0" \ " and ((now() >= din_sched) or (din_sched is null))" \