예제 #1
0
def fnUpdateRows(cur):
    global lock

    vSTATUS = ''
    vGW_RESP = ''
    vIDs = ''

    for i in range(50):  #atualiza 50 linhas no banco por vez
        try:
            r = QueueUpdate.get_nowait()

            id = r[0]
            status = r[1]
            gw_resp = r[2]

            if (status != -10):
                vSTATUS = vSTATUS + "when id = " + str(id) + " then " + str(
                    status) + " "
                vGW_RESP = vGW_RESP + "when id = " + str(
                    id) + " then '" + gw_resp + "' "
                vIDs = vIDs + str(id) + ","

            QueueUpdate.task_done()

            libextra.fnQueueControl(lock, -1)
        except Exception as e:
            break

    if vIDs == '':
        return (False)

    sql =   " UPDATE MessageQueue" \
            " SET dup = now(), status = case " \
            " "+vSTATUS+" " \
            "     end, " \
            "     gw_resp = case " \
            " "+vGW_RESP+" " \
            "     end " \
            " WHERE status in (0,15) and id in ("+vIDs+"0)"

    while True:
        try:
            #print(sql)
            cur.execute(sql)

            return (True)

        except Exception as e:
            logg.error('Loop4Ever Exception (MySQL conn problem) -> ',
                       exc_info=True)

            cur = libextra.fnMySQLConnect()
            time.sleep(5)
예제 #2
0
def fnUpdateRows(cur):
    global lock

    vSTATUS  = ''
    vGW_RESP = ''
    vIDs     = ''

    for i in range(50): #atualiza 50 linhas no banco por vez
        try:
            r = QueueUpdate.get_nowait()


            id      = r[0]
            status  = r[1]
            gw_resp = r[2]

            if (status != -10):
                vSTATUS  = vSTATUS  + "when id = "+str(id)+" then "+str(status)+" "
                vGW_RESP = vGW_RESP + "when id = "+str(id)+" then '"+gw_resp+"' "
                vIDs     = vIDs     + str(id)+","

            QueueUpdate.task_done()

            libextra.fnQueueControl(lock, -1)
        except Exception as e:
            break

    if vIDs == '':
        return(False)

    sql =   " UPDATE MessageQueue" \
            " SET dup = now(), status = case " \
            " "+vSTATUS+" " \
            "     end, " \
            "     gw_resp = case " \
            " "+vGW_RESP+" " \
            "     end " \
            " WHERE status in (0,15) and id in ("+vIDs+"0)"

    while True:
        try:
            #print(sql)
            cur.execute(sql)

            return(True)

        except Exception as e:
            logg.error('Loop4Ever Exception (MySQL conn problem) -> ', exc_info=True)

            cur = libextra.fnMySQLConnect()
            time.sleep(5)
예제 #3
0
            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))" \
예제 #4
0
            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))" \