Ejemplo n.º 1
0
def main():
    global recvnum
    global sock
    global busdata
    branchdata=[]
    while True:
        events=epoller.poll()
        for fd,flag in events:
            s=fd_socket[fd]
            if flag&(select.EPOLLIN):
               try:
                    data=s.recv(512)
                    a=np.frombuffer(data,dtype=persontype)
                    busdata=dict(zip(key,a.tolist()[0]))
                    branchdata=a['branchdata'].tolist()
                    busdata['branchdata']=branchdata[0][0:a['branchnum']]
                    update_bus_data(int(busdata['bus_id']),busdata)
                    recvnum=recvnum+1
               except Exception:
                    os._exit(3)
Ejemplo n.º 2
0
def main():
    global recvnum
    global sock
    while True:
        events=epoller.poll()
        for fd,flag in events:
            s=fd_socket[fd]
            if flag&(select.EPOLLIN):
                try:
                    data=s.recv(512)
                    a=np.frombuffer(data,dtype=persontype)
                    busdata=dict(zip(key,a.tolist()[0]))
                    branchdata=a['branchdata'].tolist()
                    busdata['branchdata']=branchdata[0][0:a['branchnum']]
                    #insert_bus_data(busdata)
                    update_bus_data(busdata['bus_id'],busdata)
                    updater.update_matrix(data)
                    recvnum=recvnum+1
                except Exception:
                    error = traceback.format_exc()
                    error_log.write(str(datetime.datetime.now())+ '\n' + error + '============================\n')
                    error_log.close()
                    os._exit(2)